diff options
Diffstat (limited to 'libc/sysdeps')
52 files changed, 701 insertions, 296 deletions
diff --git a/libc/sysdeps/alpha/fpu/bits/mathinline.h b/libc/sysdeps/alpha/fpu/bits/mathinline.h index 250171eeb..5378a181c 100644 --- a/libc/sysdeps/alpha/fpu/bits/mathinline.h +++ b/libc/sysdeps/alpha/fpu/bits/mathinline.h @@ -23,7 +23,7 @@ # error "Never use <bits/mathinline.h> directly; include <math.h> instead." #endif -#ifdef __cplusplus +#ifndef __extern_inline # define __MATH_INLINE __inline #else # define __MATH_INLINE __extern_inline diff --git a/libc/sysdeps/generic/ldsodefs.h b/libc/sysdeps/generic/ldsodefs.h index aefd105f0..147bffb96 100644 --- a/libc/sysdeps/generic/ldsodefs.h +++ b/libc/sysdeps/generic/ldsodefs.h @@ -845,7 +845,9 @@ enum DL_LOOKUP_ADD_DEPENDENCY = 1, /* Return most recent version instead of default version for unversioned lookup. */ - DL_LOOKUP_RETURN_NEWEST = 2 + DL_LOOKUP_RETURN_NEWEST = 2, + /* Set if dl_lookup* called with GSCOPE lock held. */ + DL_LOOKUP_GSCOPE_LOCK = 4, }; /* Lookup versioned symbol. */ diff --git a/libc/sysdeps/i386/fpu/bits/mathinline.h b/libc/sysdeps/i386/fpu/bits/mathinline.h index a0f630e24..a786cc69c 100644 --- a/libc/sysdeps/i386/fpu/bits/mathinline.h +++ b/libc/sysdeps/i386/fpu/bits/mathinline.h @@ -23,7 +23,7 @@ # error "Never use <bits/mathinline.h> directly; include <math.h> instead." #endif -#ifdef __cplusplus +#ifndef __extern_inline # define __MATH_INLINE __inline #else # define __MATH_INLINE __extern_inline diff --git a/libc/sysdeps/i386/i486/bits/string.h b/libc/sysdeps/i386/i486/bits/string.h index 2db9abc9e..cf5f4847f 100644 --- a/libc/sysdeps/i386/i486/bits/string.h +++ b/libc/sysdeps/i386/i486/bits/string.h @@ -32,7 +32,7 @@ && defined __GNUC__ && __GNUC__ >= 2 && !__BOUNDED_POINTERS__ #ifndef __STRING_INLINE -# ifdef __cplusplus +# ifndef __extern_inline # define __STRING_INLINE inline # else # define __STRING_INLINE __extern_inline diff --git a/libc/sysdeps/i386/i586/memcpy.S b/libc/sysdeps/i386/i586/memcpy.S index 6ab457fc5..677a7e620 100644 --- a/libc/sysdeps/i386/i586/memcpy.S +++ b/libc/sysdeps/i386/i586/memcpy.S @@ -35,6 +35,13 @@ #define LEN SRC+PTR_SIZE .text +#if defined PIC && !defined NOT_IN_libc +ENTRY (__memcpy_chk) + movl 12(%esp), %eax + cmpl %eax, 16(%esp) + jb HIDDEN_JUMPTARGET (__chk_fail) +END (__memcpy_chk) +#endif ENTRY (BP_SYM (memcpy)) ENTER diff --git a/libc/sysdeps/i386/i586/mempcpy.S b/libc/sysdeps/i386/i586/mempcpy.S index 0c9520e3b..f492be7ca 100644 --- a/libc/sysdeps/i386/i586/mempcpy.S +++ b/libc/sysdeps/i386/i586/mempcpy.S @@ -1,4 +1,5 @@ #define memcpy __mempcpy +#define __memcpy_chk __mempcpy_chk #include <sysdeps/i386/i586/memcpy.S> libc_hidden_def (BP_SYM (__mempcpy)) diff --git a/libc/sysdeps/i386/i586/memset.S b/libc/sysdeps/i386/i586/memset.S index c21e9f7a7..3295b48e7 100644 --- a/libc/sysdeps/i386/i586/memset.S +++ b/libc/sysdeps/i386/i586/memset.S @@ -38,6 +38,13 @@ #endif .text +#if defined PIC && !defined NOT_IN_libc && !BZERO_P +ENTRY (__memset_chk) + movl 12(%esp), %eax + cmpl %eax, 16(%esp) + jb HIDDEN_JUMPTARGET (__chk_fail) +END (__memset_chk) +#endif ENTRY (BP_SYM (memset)) ENTER diff --git a/libc/sysdeps/ia64/fpu/bits/mathinline.h b/libc/sysdeps/ia64/fpu/bits/mathinline.h index 1e9025718..cd90b06d3 100644 --- a/libc/sysdeps/ia64/fpu/bits/mathinline.h +++ b/libc/sysdeps/ia64/fpu/bits/mathinline.h @@ -21,7 +21,7 @@ # error "Never use <bits/mathinline.h> directly; include <math.h> instead." #endif -#ifdef __cplusplus +#ifndef __extern_inline # define __MATH_INLINE __inline #else # define __MATH_INLINE __extern_inline diff --git a/libc/sysdeps/ieee754/ldbl-opt/Makefile b/libc/sysdeps/ieee754/ldbl-opt/Makefile index 7f7bc3ce3..ce2d2d5d1 100644 --- a/libc/sysdeps/ieee754/ldbl-opt/Makefile +++ b/libc/sysdeps/ieee754/ldbl-opt/Makefile @@ -35,7 +35,11 @@ libnldbl-calls = asprintf dprintf fprintf fscanf fwprintf fwscanf iovfscanf \ jn yn ilogb remquo lrint lround llrint llround nexttowardf \ nexttoward conj cacos cacosh casin catan catanh ccos ccosh \ casinh cexp clog cproj csin csinh csqrt ctan ctanh cpow \ - cabs carg cimag creal clog10 + cabs carg cimag creal clog10 \ + isoc99_scanf isoc99_fscanf isoc99_sscanf \ + isoc99_vscanf isoc99_vfscanf isoc99_vsscanf \ + isoc99_wscanf isoc99_fwscanf isoc99_swscanf \ + isoc99_vwscanf isoc99_vfwscanf isoc99_vswscanf libnldbl-routines = $(libnldbl-calls:%=nldbl-%) libnldbl-inhibit-o = $(object-suffixes) libnldbl-static-only-routines = $(libnldbl-routines) diff --git a/libc/sysdeps/ieee754/ldbl-opt/Versions b/libc/sysdeps/ieee754/ldbl-opt/Versions index d22b18ec8..74fb3383a 100644 --- a/libc/sysdeps/ieee754/ldbl-opt/Versions +++ b/libc/sysdeps/ieee754/ldbl-opt/Versions @@ -65,6 +65,14 @@ libc { __nldbl___swprintf_chk; __nldbl___vswprintf_chk; __nldbl___fwprintf_chk; __nldbl___wprintf_chk; __nldbl___vfwprintf_chk; __nldbl___vwprintf_chk; } + GLIBC_2.7 { + __nldbl___isoc99_scanf; __nldbl___isoc99_fscanf; + __nldbl___isoc99_sscanf; __nldbl___isoc99_vscanf; + __nldbl___isoc99_vfscanf; __nldbl___isoc99_vsscanf; + __nldbl___isoc99_wscanf; __nldbl___isoc99_fwscanf; + __nldbl___isoc99_swscanf; __nldbl___isoc99_vwscanf; + __nldbl___isoc99_vfwscanf; __nldbl___isoc99_vswscanf; + } } libm { NLDBL_VERSION { diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-compat.c index f82c5f60b..b87f3bc47 100644 --- a/libc/sysdeps/ieee754/ldbl-opt/nldbl-compat.c +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-compat.c @@ -1,5 +1,5 @@ /* *printf* family compatibility routines for IEEE double as long double - 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 Jakub Jelinek <jakub@cygnus.com>, 2006. @@ -50,6 +50,10 @@ libc_hidden_proto (__nldbl___vsprintf_chk) libc_hidden_proto (__nldbl___vswprintf_chk) libc_hidden_proto (__nldbl___vstrfmon) libc_hidden_proto (__nldbl___vstrfmon_l) +libc_hidden_proto (__nldbl___isoc99_vsscanf) +libc_hidden_proto (__nldbl___isoc99_vfscanf) +libc_hidden_proto (__nldbl___isoc99_vswscanf) +libc_hidden_proto (__nldbl___isoc99_vfwscanf) static void __nldbl_cleanup (void *arg) @@ -782,6 +786,153 @@ __nldbl_vsyslog (int pri, const char *fmt, va_list ap) __nldbl___vsyslog_chk (pri, -1, fmt, ap); } +int +attribute_compat_text_section +__nldbl___isoc99_vfscanf (FILE *s, const char *fmt, va_list ap) +{ + int res; + set_no_long_double (); + res = __isoc99_vfscanf (s, fmt, ap); + clear_no_long_double (); + return res; +} +libc_hidden_def (__nldbl___isoc99_vfscanf) + +int +attribute_compat_text_section +__nldbl___isoc99_sscanf (const char *s, const char *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___isoc99_vsscanf (s, fmt, arg); + va_end (arg); + + return done; +} + +int +attribute_compat_text_section +__nldbl___isoc99_vsscanf (const char *string, const char *fmt, va_list ap) +{ + int res; + __no_long_double = 1; + res = __isoc99_vsscanf (string, fmt, ap); + __no_long_double = 0; + return res; +} +libc_hidden_def (__nldbl___isoc99_vsscanf) + +int +attribute_compat_text_section +__nldbl___isoc99_vscanf (const char *fmt, va_list ap) +{ + return __nldbl___isoc99_vfscanf (stdin, fmt, ap); +} + +int +attribute_compat_text_section +__nldbl___isoc99_fscanf (FILE *stream, const char *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___isoc99_vfscanf (stream, fmt, arg); + va_end (arg); + + return done; +} + +int +attribute_compat_text_section +__nldbl___isoc99_scanf (const char *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___isoc99_vfscanf (stdin, fmt, arg); + va_end (arg); + + return done; +} + +int +attribute_compat_text_section +__nldbl___isoc99_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap) +{ + int res; + set_no_long_double (); + res = __isoc99_vfwscanf (s, fmt, ap); + clear_no_long_double (); + return res; +} +libc_hidden_def (__nldbl___isoc99_vfwscanf) + +int +attribute_compat_text_section +__nldbl___isoc99_swscanf (const wchar_t *s, const wchar_t *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___isoc99_vswscanf (s, fmt, arg); + va_end (arg); + + return done; +} + +int +attribute_compat_text_section +__nldbl___isoc99_vswscanf (const wchar_t *string, const wchar_t *fmt, + va_list ap) +{ + int res; + __no_long_double = 1; + res = __isoc99_vswscanf (string, fmt, ap); + __no_long_double = 0; + return res; +} +libc_hidden_def (__nldbl___isoc99_vswscanf) + +int +attribute_compat_text_section +__nldbl___isoc99_vwscanf (const wchar_t *fmt, va_list ap) +{ + return __nldbl___isoc99_vfwscanf (stdin, fmt, ap); +} + +int +attribute_compat_text_section +__nldbl___isoc99_fwscanf (FILE *stream, const wchar_t *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___isoc99_vfwscanf (stream, fmt, arg); + va_end (arg); + + return done; +} + +int +attribute_compat_text_section +__nldbl___isoc99_wscanf (const wchar_t *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___isoc99_vfwscanf (stdin, fmt, arg); + va_end (arg); + + return done; +} + #if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0) compat_symbol (libc, __nldbl__IO_printf, _IO_printf, GLIBC_2_0); compat_symbol (libc, __nldbl__IO_sprintf, _IO_sprintf, GLIBC_2_0); diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-compat.h b/libc/sysdeps/ieee754/ldbl-opt/nldbl-compat.h index c0461000f..c7824583d 100644 --- a/libc/sysdeps/ieee754/ldbl-opt/nldbl-compat.h +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-compat.h @@ -1,5 +1,5 @@ /* Prototypes for compatibility double == long double entry points. - 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 Jakub Jelinek <jakub@cygnus.com>, 2006. @@ -61,6 +61,18 @@ NLDBL_DECL (qecvt); NLDBL_DECL (qfcvt); NLDBL_DECL (qgcvt); NLDBL_DECL (__vstrfmon_l); +NLDBL_DECL (__isoc99_scanf); +NLDBL_DECL (__isoc99_fscanf); +NLDBL_DECL (__isoc99_sscanf); +NLDBL_DECL (__isoc99_vscanf); +NLDBL_DECL (__isoc99_vfscanf); +NLDBL_DECL (__isoc99_vsscanf); +NLDBL_DECL (__isoc99_wscanf); +NLDBL_DECL (__isoc99_fwscanf); +NLDBL_DECL (__isoc99_swscanf); +NLDBL_DECL (__isoc99_vwscanf); +NLDBL_DECL (__isoc99_vfwscanf); +NLDBL_DECL (__isoc99_vswscanf); /* This one does not exist in the normal interface, only __nldbl___vstrfmon really exists. */ diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_fscanf.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_fscanf.c new file mode 100644 index 000000000..1d736668a --- /dev/null +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_fscanf.c @@ -0,0 +1,15 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__isoc99_fscanf (FILE *stream, const char *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___isoc99_vfscanf (stream, fmt, arg); + va_end (arg); + + return done; +} diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_fwscanf.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_fwscanf.c new file mode 100644 index 000000000..dbea1512c --- /dev/null +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_fwscanf.c @@ -0,0 +1,15 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__isoc99_fwscanf (FILE *stream, const wchar_t *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___isoc99_vfwscanf (stream, fmt, arg); + va_end (arg); + + return done; +} diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_scanf.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_scanf.c new file mode 100644 index 000000000..ec2ec5329 --- /dev/null +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_scanf.c @@ -0,0 +1,15 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__isoc99_scanf (const char *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___isoc99_vfscanf (stdin, fmt, arg); + va_end (arg); + + return done; +} diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_sscanf.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_sscanf.c new file mode 100644 index 000000000..52e1bd5d2 --- /dev/null +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_sscanf.c @@ -0,0 +1,15 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__isoc99_sscanf (const char *s, const char *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___isoc99_vsscanf (s, fmt, arg); + va_end (arg); + + return done; +} diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_swscanf.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_swscanf.c new file mode 100644 index 000000000..927d02492 --- /dev/null +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_swscanf.c @@ -0,0 +1,15 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__isoc99_swscanf (const wchar_t *s, const wchar_t *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___isoc99_vswscanf (s, fmt, arg); + va_end (arg); + + return done; +} diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vfscanf.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vfscanf.c new file mode 100644 index 000000000..55556c375 --- /dev/null +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vfscanf.c @@ -0,0 +1,8 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__isoc99_vfscanf (FILE *s, const char *fmt, va_list ap) +{ + return __nldbl___isoc99_vfscanf (s, fmt, ap); +} diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vfwscanf.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vfwscanf.c new file mode 100644 index 000000000..4fd54cb17 --- /dev/null +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vfwscanf.c @@ -0,0 +1,8 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__isoc99_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap) +{ + return __nldbl___isoc99_vfwscanf (s, fmt, ap); +} diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vscanf.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vscanf.c new file mode 100644 index 000000000..6284c9339 --- /dev/null +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vscanf.c @@ -0,0 +1,8 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__isoc99_vscanf (const char *fmt, va_list ap) +{ + return __nldbl___isoc99_vfscanf (stdin, fmt, ap); +} diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vsscanf.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vsscanf.c new file mode 100644 index 000000000..0c19032b1 --- /dev/null +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vsscanf.c @@ -0,0 +1,8 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__isoc99_vsscanf (const char *string, const char *fmt, va_list ap) +{ + return __nldbl___isoc99_vsscanf (string, fmt, ap); +} diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vswscanf.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vswscanf.c new file mode 100644 index 000000000..5f34221b6 --- /dev/null +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vswscanf.c @@ -0,0 +1,8 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__isoc99_vswscanf (const wchar_t *string, const wchar_t *fmt, va_list ap) +{ + return __nldbl___isoc99_vswscanf (string, fmt, ap); +} diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vwscanf.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vwscanf.c new file mode 100644 index 000000000..a8a76ff54 --- /dev/null +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_vwscanf.c @@ -0,0 +1,8 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__isoc99_vwscanf (const wchar_t *fmt, va_list ap) +{ + return __nldbl___isoc99_vfwscanf (stdin, fmt, ap); +} diff --git a/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_wscanf.c b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_wscanf.c new file mode 100644 index 000000000..fc2f6f859 --- /dev/null +++ b/libc/sysdeps/ieee754/ldbl-opt/nldbl-isoc99_wscanf.c @@ -0,0 +1,15 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__isoc99_wscanf (const wchar_t *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___isoc99_vfwscanf (stdin, fmt, arg); + va_end (arg); + + return done; +} diff --git a/libc/sysdeps/posix/getaddrinfo.c b/libc/sysdeps/posix/getaddrinfo.c index adb3c4f96..221b41dd0 100644 --- a/libc/sysdeps/posix/getaddrinfo.c +++ b/libc/sysdeps/posix/getaddrinfo.c @@ -1944,6 +1944,9 @@ getaddrinfo (const char *name, const char *service, if (in6ai != NULL) qsort (in6ai, in6ailen, sizeof (*in6ai), in6aicmp); + int fd = -1; + int af = AF_UNSPEC; + for (i = 0, q = p; q != NULL; ++i, last = q, q = q->ai_next) { results[i].dest_addr = q; @@ -1968,7 +1971,21 @@ getaddrinfo (const char *name, const char *service, want connect() to connect to the other side. If we cannot determine the source address remember this fact. */ - int fd = __socket (q->ai_family, SOCK_DGRAM, IPPROTO_IP); + if (fd == -1 || (af == AF_INET && q->ai_family == AF_INET6)) + { + if (fd != -1) + close_retry: + close_not_cancel_no_status (fd); + af = q->ai_family; + fd = __socket (af, SOCK_DGRAM, IPPROTO_IP); + } + else + { + /* Reset the connection. */ + struct sockaddr sa = { .sa_family = AF_UNSPEC }; + __connect (fd, &sa, sizeof (sa)); + } + socklen_t sl = sizeof (results[i].source_addr); if (fd != -1 && __connect (fd, q->ai_addr, q->ai_addrlen) == 0 @@ -1979,9 +1996,9 @@ getaddrinfo (const char *name, const char *service, results[i].source_addr_len = sl; results[i].got_source_addr = true; - if (q->ai_family == PF_INET6 && in6ai != NULL) + if (q->ai_family == AF_INET6 && in6ai != NULL) { - /* See whether the source address is the list of + /* See whether the source address is on the list of deprecated or temporary addresses. */ struct in6addrinfo tmp; struct sockaddr_in6 *sin6p @@ -1994,14 +2011,29 @@ getaddrinfo (const char *name, const char *service, if (found != NULL) results[i].source_addr_flags = found->flags; } + else if (q->ai_family == AF_INET && af == AF_INET6) + { + /* We have to convert the address. The socket is + IPv6 and the request is for IPv4. */ + struct sockaddr_in6 *sin6 + = (struct sockaddr_in6 *) &results[i].source_addr; + struct sockaddr_in *sin + = (struct sockaddr_in *) &results[i].source_addr; + assert (IN6_IS_ADDR_V4MAPPED (sin6->sin6_addr.s6_addr32)); + memcpy (&sin->sin_addr, + &sin6->sin6_addr.s6_addr32[3], INADDRSZ); + results[i].source_addr_len = INADDRSZ; + sin->sin_family = AF_INET; + } } + else if (errno == EAFNOSUPPORT && af == AF_INET6 + && q->ai_family == AF_INET) + /* This could mean IPv6 sockets are IPv6-only. */ + goto close_retry; else /* Just make sure that if we have to process the same address again we do not copy any memory. */ results[i].source_addr_len = 0; - - if (fd != -1) - close_not_cancel_no_status (fd); } /* Remember the canonical name. */ @@ -2013,6 +2045,9 @@ getaddrinfo (const char *name, const char *service, } } + if (fd != -1) + close_not_cancel_no_status (fd); + /* We got all the source addresses we can get, now sort using the information. */ qsort (results, nresults, sizeof (results[0]), rfc3484_sort); diff --git a/libc/sysdeps/powerpc/fpu/bits/mathinline.h b/libc/sysdeps/powerpc/fpu/bits/mathinline.h index bcb9098f8..c5d458582 100644 --- a/libc/sysdeps/powerpc/fpu/bits/mathinline.h +++ b/libc/sysdeps/powerpc/fpu/bits/mathinline.h @@ -22,7 +22,7 @@ # error "Never use <bits/mathinline.h> directly; include <math.h> instead." #endif -#ifdef __cplusplus +#ifndef __extern_inline # define __MATH_INLINE __inline #else # define __MATH_INLINE __extern_inline diff --git a/libc/sysdeps/s390/bits/string.h b/libc/sysdeps/s390/bits/string.h index e16c7cb82..87550c5f6 100644 --- a/libc/sysdeps/s390/bits/string.h +++ b/libc/sysdeps/s390/bits/string.h @@ -31,7 +31,7 @@ && defined __GNUC__ && __GNUC__ >= 2 #ifndef __STRING_INLINE -# ifdef __cplusplus +# ifndef __extern_inline # define __STRING_INLINE inline # else # define __STRING_INLINE __extern_inline diff --git a/libc/sysdeps/s390/fpu/bits/mathinline.h b/libc/sysdeps/s390/fpu/bits/mathinline.h index 06a636845..03af01c2b 100644 --- a/libc/sysdeps/s390/fpu/bits/mathinline.h +++ b/libc/sysdeps/s390/fpu/bits/mathinline.h @@ -21,7 +21,7 @@ # error "Never use <bits/mathinline.h> directly; include <math.h> instead." #endif -#ifdef __cplusplus +#ifndef __extern_inline # define __MATH_INLINE __inline #else # define __MATH_INLINE __extern_inline diff --git a/libc/sysdeps/sparc/fpu/bits/mathinline.h b/libc/sysdeps/sparc/fpu/bits/mathinline.h index 16ad22e66..d3ff44c5a 100644 --- a/libc/sysdeps/sparc/fpu/bits/mathinline.h +++ b/libc/sysdeps/sparc/fpu/bits/mathinline.h @@ -128,7 +128,7 @@ #if (!defined __NO_MATH_INLINES || defined __LIBC_INTERNAL_MATH_INLINES) && defined __OPTIMIZE__ -# ifdef __cplusplus +# ifndef __extern_inline # define __MATH_INLINE __inline # else # define __MATH_INLINE __extern_inline diff --git a/libc/sysdeps/sparc/sparc32/elf/start.S b/libc/sysdeps/sparc/sparc32/elf/start.S index 702dd755e..85adb7322 100644 --- a/libc/sysdeps/sparc/sparc32/elf/start.S +++ b/libc/sysdeps/sparc/sparc32/elf/start.S @@ -1,5 +1,5 @@ /* Startup code for elf32-sparc - Copyright (C) 1997, 1998, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2002, 2004, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997. @@ -48,8 +48,6 @@ .global _start .type _start,#function _start: - cfi_startproc - #ifdef SHARED sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7 call .LLGETPC0 @@ -60,7 +58,6 @@ _start: drop their arguments. */ mov %g0, %fp sub %sp, 6*4, %sp - cfi_adjust_cfa_offset(6*4) /* Extract the arguments and environment as encoded on the stack. The argument info starts after one register window (16 words) past the SP. */ @@ -93,8 +90,6 @@ _start: /* Die very horribly if exit returns. */ unimp - cfi_endproc - .size _start, .-_start /* Define a symbol for the first piece of initialized data. */ diff --git a/libc/sysdeps/sparc/sparc64/elf/start.S b/libc/sysdeps/sparc/sparc64/elf/start.S index df44cae06..650d3d304 100644 --- a/libc/sysdeps/sparc/sparc64/elf/start.S +++ b/libc/sysdeps/sparc/sparc64/elf/start.S @@ -1,5 +1,5 @@ /* Startup code for elf64-sparc - Copyright (C) 1997, 1998, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 2002, 2004, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997. @@ -48,8 +48,6 @@ .global _start .type _start,#function _start: - cfi_startproc - #ifdef SHARED sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %l7 call .LLGETPC0 @@ -60,7 +58,6 @@ _start: drop their arguments. */ mov %g0, %fp sub %sp, 6*8, %sp - cfi_adjust_cfa_offset(6*8) /* Extract the arguments and environment as encoded on the stack. The argument info starts after one register window (16 words) past the SP, @@ -94,8 +91,6 @@ _start: /* Die very horribly if exit returns. */ illtrap 0 - cfi_endproc - .size _start, .-_start /* Define a symbol for the first piece of initialized data. */ diff --git a/libc/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h index b4f49cf63..7c93183ad 100644 --- a/libc/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/alpha/bits/fcntl.h @@ -213,17 +213,17 @@ extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, /* Splice address range into a pipe. */ -extern int vmsplice (int __fdout, const struct iovec *__iov, size_t __count, - unsigned int __flags); +extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, + size_t __count, unsigned int __flags); /* Splice two files together. */ -extern int splice (int __fdin, __off64_t *__offin, int __fdout, - __off64_t *__offout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, + __off64_t *__offout, size_t __len, + unsigned int __flags); /* In-kernel implementation of tee for pipe buffers. */ -extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t tee (int __fdin, int __fdout, size_t __len, + unsigned int __flags); #endif diff --git a/libc/sysdeps/unix/sysv/linux/i386/Makefile b/libc/sysdeps/unix/sysv/linux/i386/Makefile index 9e8497563..f52ee89f0 100644 --- a/libc/sysdeps/unix/sysv/linux/i386/Makefile +++ b/libc/sysdeps/unix/sysv/linux/i386/Makefile @@ -1,5 +1,5 @@ ifeq ($(subdir),misc) -sysdep_routines += ioperm iopl vm86 call_pselect6 +sysdep_routines += ioperm iopl vm86 call_pselect6 call_fallocate sysdep_headers += sys/elf.h sys/perm.h sys/reg.h sys/vm86.h sys/debugreg.h sys/io.h endif diff --git a/libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h index 83ca3c286..1ad51ad6b 100644 --- a/libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/i386/bits/fcntl.h @@ -221,17 +221,17 @@ extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, /* Splice address range into a pipe. */ -extern int vmsplice (int __fdout, const struct iovec *__iov, size_t __count, - unsigned int __flags); +extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, + size_t __count, unsigned int __flags); /* Splice two files together. */ -extern int splice (int __fdin, __off64_t *__offin, int __fdout, - __off64_t *__offout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, + __off64_t *__offout, size_t __len, + unsigned int __flags); /* In-kernel implementation of tee for pipe buffers. */ -extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t tee (int __fdin, int __fdout, size_t __len, + unsigned int __flags); #endif diff --git a/libc/sysdeps/unix/sysv/linux/i386/call_fallocate.S b/libc/sysdeps/unix/sysv/linux/i386/call_fallocate.S new file mode 100644 index 000000000..39ab7979c --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/i386/call_fallocate.S @@ -0,0 +1,7 @@ +#include <sysdep.h> + +#ifdef __NR_fallocate +PSEUDO_ERRVAL (__call_fallocate, fallocate, 6) + ret_ERRVAL +PSEUDO_END_ERRVAL(__call_fallocate) +#endif diff --git a/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate.c b/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate.c index c974d06af..9ac7b3848 100644 --- a/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate.c +++ b/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate.c @@ -28,7 +28,7 @@ int __have_fallocate attribute_hidden; #endif -extern int __fallocate64 (int fd, int mode, __off64_t offset, __off64_t len) +extern int __call_fallocate (int fd, int mode, __off64_t offset, __off64_t len) attribute_hidden; /* Reserve storage for the data of the file associated with FD. */ @@ -40,7 +40,7 @@ posix_fallocate (int fd, __off_t offset, __off_t len) if (__builtin_expect (__have_fallocate >= 0, 1)) # endif { - int res = __fallocate64 (fd, 0, offset, len); + int res = __call_fallocate (fd, 0, offset, len); if (! res) return 0; diff --git a/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c b/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c index d5b4d597c..f1ed7e315 100644 --- a/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c +++ b/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c @@ -30,7 +30,7 @@ extern int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len); extern int __have_fallocate attribute_hidden; #endif -extern int __fallocate64 (int fd, int mode, __off64_t offset, __off64_t len) +extern int __call_fallocate (int fd, int mode, __off64_t offset, __off64_t len) attribute_hidden; /* Reserve storage for the data of the file associated with FD. */ @@ -42,7 +42,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len) if (__builtin_expect (__have_fallocate >= 0, 1)) # endif { - int res = __fallocate64 (fd, 0, offset, len); + int res = __call_fallocate (fd, 0, offset, len); if (! res) return 0; diff --git a/libc/sysdeps/unix/sysv/linux/i386/syscalls.list b/libc/sysdeps/unix/sysv/linux/i386/syscalls.list index 324ab3dc1..3ff3a73aa 100644 --- a/libc/sysdeps/unix/sysv/linux/i386/syscalls.list +++ b/libc/sysdeps/unix/sysv/linux/i386/syscalls.list @@ -6,4 +6,3 @@ 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/ia64/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h index 8fa96e4e2..69bc39f69 100644 --- a/libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h @@ -215,17 +215,17 @@ extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, /* Splice address range into a pipe. */ -extern int vmsplice (int __fdout, const struct iovec *__iov, size_t __count, - unsigned int __flags); +extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, + size_t __count, unsigned int __flags); /* Splice two files together. */ -extern int splice (int __fdin, __off64_t *__offin, int __fdout, - __off64_t *__offout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, + __off64_t *__offout, size_t __len, + unsigned int __flags); /* In-kernel implementation of tee for pipe buffers. */ -extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t tee (int __fdin, int __fdout, size_t __len, + unsigned int __flags); #endif diff --git a/libc/sysdeps/unix/sysv/linux/mq_open.c b/libc/sysdeps/unix/sysv/linux/mq_open.c index eac6e0123..6330fee4e 100644 --- a/libc/sysdeps/unix/sysv/linux/mq_open.c +++ b/libc/sysdeps/unix/sysv/linux/mq_open.c @@ -1,4 +1,4 @@ -/* 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 @@ -20,6 +20,7 @@ #include <mqueue.h> #include <stdarg.h> #include <stddef.h> +#include <stdio.h> #include <sysdep.h> #ifdef __NR_mq_open @@ -32,7 +33,7 @@ attributes. If the fourth argument is NULL, default attributes are used. */ mqd_t -mq_open (const char *name, int oflag, ...) +__mq_open (const char *name, int oflag, ...) { if (name[0] != '/') { @@ -54,7 +55,16 @@ mq_open (const char *name, int oflag, ...) return INLINE_SYSCALL (mq_open, 4, name + 1, oflag, mode, attr); } +strong_alias (__mq_open, mq_open); +mqd_t +__mq_open_2 (const char *name, int oflag) +{ + if (oflag & O_CREAT) + __fortify_fail ("invalid mq_open call: O_CREAT without mode and attr"); + + return __mq_open (name, oflag); +} #else # include <rt/mq_open.c> #endif diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h index 68015dbca..0ad99b5ea 100644 --- a/libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/powerpc/bits/fcntl.h @@ -221,17 +221,17 @@ extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, /* Splice address range into a pipe. */ -extern int vmsplice (int __fdout, const struct iovec *__iov, size_t __count, - unsigned int __flags); +extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, + size_t __count, unsigned int __flags); /* Splice two files together. */ -extern int splice (int __fdin, __off64_t *__offin, int __fdout, - __off64_t *__offout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, + __off64_t *__offout, size_t __len, + unsigned int __flags); /* In-kernel implementation of tee for pipe buffers. */ -extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t tee (int __fdin, int __fdout, size_t __len, + unsigned int __flags); #endif diff --git a/libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h index 848568532..c26e0e771 100644 --- a/libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/s390/bits/fcntl.h @@ -241,17 +241,17 @@ extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, /* Splice address range into a pipe. */ -extern int vmsplice (int __fdout, const struct iovec *__iov, size_t __count, - unsigned int __flags); +extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, + size_t __count, unsigned int __flags); /* Splice two files together. */ -extern int splice (int __fdin, __off64_t *__offin, int __fdout, - __off64_t *__offout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, + __off64_t *__offout, size_t __len, + unsigned int __flags); /* In-kernel implementation of tee for pipe buffers. */ -extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t tee (int __fdin, int __fdout, size_t __len, + unsigned int __flags); #endif diff --git a/libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h index 83ca3c286..1ad51ad6b 100644 --- a/libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/sh/bits/fcntl.h @@ -221,17 +221,17 @@ extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, /* Splice address range into a pipe. */ -extern int vmsplice (int __fdout, const struct iovec *__iov, size_t __count, - unsigned int __flags); +extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, + size_t __count, unsigned int __flags); /* Splice two files together. */ -extern int splice (int __fdin, __off64_t *__offin, int __fdout, - __off64_t *__offout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, + __off64_t *__offout, size_t __len, + unsigned int __flags); /* In-kernel implementation of tee for pipe buffers. */ -extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t tee (int __fdin, int __fdout, size_t __len, + unsigned int __flags); #endif diff --git a/libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h b/libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h index 2307a2353..ebfeb605a 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h @@ -240,17 +240,17 @@ extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, /* Splice address range into a pipe. */ -extern int vmsplice (int __fdout, const struct iovec *__iov, size_t __count, - unsigned int __flags); +extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, + size_t __count, unsigned int __flags); /* Splice two files together. */ -extern int splice (int __fdin, __off64_t *__offin, int __fdout, - __off64_t *__offout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, + __off64_t *__offout, size_t __len, + unsigned int __flags); /* In-kernel implementation of tee for pipe buffers. */ -extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t tee (int __fdin, int __fdout, size_t __len, + unsigned int __flags); #endif diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S index a64d8e519..b623bfb8d 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc32/clone.S @@ -82,8 +82,6 @@ END(__clone) .type __thread_start,@function __thread_start: - cfi_startproc - #ifdef RESET_PID sethi %hi(CLONE_THREAD), %l0 andcc %g4, %l0, %g0 @@ -104,8 +102,6 @@ __thread_start: call HIDDEN_JUMPTARGET(_exit),0 nop - cfi_endproc - .size __thread_start, .-__thread_start weak_alias (__clone, clone) diff --git a/libc/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S b/libc/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S index 2bbbd8020..9d101e239 100644 --- a/libc/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S +++ b/libc/sysdeps/unix/sysv/linux/sparc/sparc64/clone.S @@ -78,7 +78,6 @@ END(__clone) .type __thread_start,@function __thread_start: - cfi_startproc #ifdef RESET_PID sethi %hi(CLONE_THREAD), %l0 andcc %g4, %l0, %g0 @@ -97,7 +96,6 @@ __thread_start: mov %g3,%o0 call HIDDEN_JUMPTARGET(_exit),0 nop - cfi_endproc .size __thread_start, .-__thread_start diff --git a/libc/sysdeps/unix/sysv/linux/sys/sysmacros.h b/libc/sysdeps/unix/sysv/linux/sys/sysmacros.h index e59672980..92b3a19d4 100644 --- a/libc/sysdeps/unix/sysv/linux/sys/sysmacros.h +++ b/libc/sysdeps/unix/sysv/linux/sys/sysmacros.h @@ -28,17 +28,17 @@ they need. */ #ifdef __GLIBC_HAVE_LONG_LONG __extension__ -__extern_inline unsigned int gnu_dev_major (unsigned long long int __dev) +extern unsigned int gnu_dev_major (unsigned long long int __dev) __THROW; __extension__ -__extern_inline unsigned int gnu_dev_minor (unsigned long long int __dev) +extern unsigned int gnu_dev_minor (unsigned long long int __dev) __THROW; __extension__ -__extern_inline unsigned long long int gnu_dev_makedev (unsigned int __major, - unsigned int __minor) +extern unsigned long long int gnu_dev_makedev (unsigned int __major, + unsigned int __minor) __THROW; -# if defined __GNUC__ && __GNUC__ >= 2 +# if defined __GNUC__ && __GNUC__ >= 2 && defined __USE_EXTERN_INLINES __extension__ __extern_inline unsigned int __NTH (gnu_dev_major (unsigned long long int __dev)) { diff --git a/libc/sysdeps/unix/sysv/linux/syscalls.list b/libc/sysdeps/unix/sysv/linux/syscalls.list index 7e5cc7050..e304a78ea 100644 --- a/libc/sysdeps/unix/sysv/linux/syscalls.list +++ b/libc/sysdeps/unix/sysv/linux/syscalls.list @@ -66,14 +66,14 @@ setfsgid EXTRA setfsgid i:i setfsgid setfsuid EXTRA setfsuid i:i setfsuid setpgid - setpgid i:ii __setpgid setpgid sigaltstack - sigaltstack i:PP __sigaltstack sigaltstack -splice EXTRA splice i:iPiPii splice +splice EXTRA splice Ci:iPiPii splice sysinfo EXTRA sysinfo i:p sysinfo swapon - swapon i:si __swapon swapon swapoff - swapoff i:s __swapoff swapoff -tee EXTRA tee i:iiii tee +tee EXTRA tee Ci:iiii tee unshare EXTRA unshare i:i unshare uselib EXTRA uselib i:s uselib -vmsplice EXTRA vmsplice i:iPii vmsplice +vmsplice EXTRA vmsplice Ci:iPii vmsplice wait4 - wait4 i:iWiP __wait4 wait4 chown - chown i:sii __libc_chown __chown chown 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 a918a0725..f1fd3c4e4 100644 --- a/libc/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h +++ b/libc/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h @@ -235,17 +235,17 @@ extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, /* Splice address range into a pipe. */ -extern int vmsplice (int __fdout, const struct iovec *__iov, size_t __count, - unsigned int __flags); +extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, + size_t __count, unsigned int __flags); /* Splice two files together. */ -extern int splice (int __fdin, __off64_t *__offin, int __fdout, - __off64_t *__offout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, + __off64_t *__offout, size_t __len, + unsigned int __flags); /* In-kernel implementation of tee for pipe buffers. */ -extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) - __THROW; +extern ssize_t tee (int __fdin, int __fdout, size_t __len, + unsigned int __flags); #endif diff --git a/libc/sysdeps/x86_64/cacheinfo.c b/libc/sysdeps/x86_64/cacheinfo.c index 793dc2d35..5b92bd584 100644 --- a/libc/sysdeps/x86_64/cacheinfo.c +++ b/libc/sysdeps/x86_64/cacheinfo.c @@ -398,13 +398,13 @@ __cache_sysconf (int name) } -/* Half the core cache size for use in memory and string routines, typically - L1 size. */ -long int __x86_64_core_cache_size_half attribute_hidden = 32 * 1024 / 2; +/* Half the data cache size for use in memory and string routines, typically + L1 size. */ +long int __x86_64_data_cache_size_half attribute_hidden = 32 * 1024 / 2; /* Shared cache size for use in memory and string routines, typically - L2 or L3 size. */ + L2 or L3 size. */ long int __x86_64_shared_cache_size_half attribute_hidden = 1024 * 1024 / 2; -/* PREFETCHW support flag for use in memory and string routines. */ +/* PREFETCHW support flag for use in memory and string routines. */ int __x86_64_prefetchw attribute_hidden; @@ -419,7 +419,7 @@ init_cacheinfo (void) unsigned int edx; int max_cpuid; int max_cpuid_ex; - long int core = -1; + long int data = -1; long int shared = -1; unsigned int level; unsigned int threads = 0; @@ -431,26 +431,26 @@ init_cacheinfo (void) /* This spells out "GenuineIntel". */ if (ebx == 0x756e6547 && ecx == 0x6c65746e && edx == 0x49656e69) { - core = handle_intel (_SC_LEVEL1_DCACHE_SIZE, max_cpuid); + data = handle_intel (_SC_LEVEL1_DCACHE_SIZE, max_cpuid); - /* Try L3 first. */ + /* Try L3 first. */ level = 3; shared = handle_intel (_SC_LEVEL3_CACHE_SIZE, max_cpuid); if (shared <= 0) { - /* Try L2 otherwise. */ + /* Try L2 otherwise. */ level = 2; shared = handle_intel (_SC_LEVEL2_CACHE_SIZE, max_cpuid); } /* Figure out the number of logical threads that share the - highest cache level. */ + highest cache level. */ if (max_cpuid >= 4) { int i = 0; - /* Query until desired cache level is enumerated. */ + /* Query until desired cache level is enumerated. */ do { asm volatile ("cpuid" @@ -463,7 +463,7 @@ init_cacheinfo (void) } else { - /* Assume that all logical threads share the highest cache level. */ + /* Assume that all logical threads share the highest cache level. */ asm volatile ("cpuid" : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) : "0" (1)); @@ -472,33 +472,73 @@ init_cacheinfo (void) } /* Cap usage of highest cache level to the number of supported - threads. */ + threads. */ if (shared > 0 && threads > 0) shared /= threads; } /* This spells out "AuthenticAMD". */ else if (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65) { - core = handle_amd (_SC_LEVEL1_DCACHE_SIZE); - shared = handle_amd (_SC_LEVEL2_CACHE_SIZE); + data = handle_amd (_SC_LEVEL1_DCACHE_SIZE); + long int core = handle_amd (_SC_LEVEL2_CACHE_SIZE); + shared = handle_amd (_SC_LEVEL3_CACHE_SIZE); + /* Get maximum extended function. */ asm volatile ("cpuid" : "=a" (max_cpuid_ex), "=b" (ebx), "=c" (ecx), "=d" (edx) : "0" (0x80000000)); + if (shared <= 0) + /* No shared L3 cache. All we have is the L2 cache. */ + shared = core; + else + { + /* Figure out the number of logical threads that share L3. */ + if (max_cpuid_ex >= 0x80000008) + { + /* Get width of APIC ID. */ + asm volatile ("cpuid" + : "=a" (max_cpuid_ex), "=b" (ebx), "=c" (ecx), + "=d" (edx) + : "0" (0x80000008)); + threads = 1 << ((ecx >> 12) & 0x0f); + } + + if (threads == 0) + { + /* If APIC ID width is not available, use logical + processor count. */ + asm volatile ("cpuid" + : "=a" (max_cpuid_ex), "=b" (ebx), "=c" (ecx), + "=d" (edx) + : "0" (0x00000001)); + + if ((edx & (1 << 28)) != 0) + threads = (ebx >> 16) & 0xff; + } + + /* Cap usage of highest cache level to the number of + supported threads. */ + if (threads > 0) + shared /= threads; + + /* Account for exclusive L2 and L3 caches. */ + shared += core; + } + if (max_cpuid_ex >= 0x80000001) { asm volatile ("cpuid" : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) : "0" (0x80000001)); - /* PREFETCHW || 3DNow! */ + /* PREFETCHW || 3DNow! */ if ((ecx & 0x100) || (edx & 0x80000000)) __x86_64_prefetchw = -1; } } - if (core > 0) - __x86_64_core_cache_size_half = core / 2; + if (data > 0) + __x86_64_data_cache_size_half = data / 2; if (shared > 0) __x86_64_shared_cache_size_half = shared / 2; diff --git a/libc/sysdeps/x86_64/fpu/bits/mathinline.h b/libc/sysdeps/x86_64/fpu/bits/mathinline.h index d08a9b033..e8a919fe9 100644 --- a/libc/sysdeps/x86_64/fpu/bits/mathinline.h +++ b/libc/sysdeps/x86_64/fpu/bits/mathinline.h @@ -22,7 +22,7 @@ # error "Never use <bits/mathinline.h> directly; include <math.h> instead." #endif -#ifdef __cplusplus +#ifndef __extern_inline # define __MATH_INLINE __inline #else # define __MATH_INLINE __extern_inline diff --git a/libc/sysdeps/x86_64/memcpy.S b/libc/sysdeps/x86_64/memcpy.S index 231329864..b25646b8c 100644 --- a/libc/sysdeps/x86_64/memcpy.S +++ b/libc/sysdeps/x86_64/memcpy.S @@ -114,15 +114,15 @@ L(1d): /* 16-byte loop */ .p2align 4 L(1loop): - movq (%rsi), %rcx - movq 8 (%rsi), %r8 - movq %rcx, (%rdi) - movq %r8, 8 (%rdi) + movq (%rsi), %rcx + movq 8(%rsi), %r8 + movq %rcx, (%rdi) + movq %r8, 8(%rdi) subl $16, %edx - leaq 16 (%rsi), %rsi - leaq 16 (%rdi), %rdi + leaq 16(%rsi), %rsi + leaq 16(%rdi), %rdi jnz L(1loop) @@ -140,19 +140,19 @@ L(exit): /* exit */ L(1after): #ifndef USE_AS_MEMPCPY - movq %rax, RETVAL (%rsp) /* save return value */ + movq %rax, RETVAL(%rsp) /* save return value */ #endif /* Align to the natural word size. */ L(aligntry): - movl %esi, %ecx /* align by destination */ + movl %esi, %ecx /* align by source */ andl $7, %ecx jz L(alignafter) /* already aligned */ L(align): /* align */ - leaq -8 (%rcx, %rdx), %rdx /* calculate remaining bytes */ + leaq -8(%rcx, %rdx), %rdx /* calculate remaining bytes */ subl $8, %ecx .p2align 4 @@ -163,8 +163,8 @@ L(alignloop): /* 1-byte alignment loop */ incl %ecx - leaq 1 (%rsi), %rsi - leaq 1 (%rdi), %rdi + leaq 1(%rsi), %rsi + leaq 1(%rdi), %rdi jnz L(alignloop) @@ -172,7 +172,7 @@ L(alignloop): /* 1-byte alignment loop */ L(alignafter): -/* Loop to handle mid-sized blocks. */ +/* Handle mid-sized blocks. */ L(32try): /* up to 1KB */ cmpq $1024, %rdx @@ -188,15 +188,15 @@ L(32): /* 32-byte loop */ L(32loop): decl %ecx - movq (%rsi), %rax - movq 8 (%rsi), %r8 - movq 16 (%rsi), %r9 - movq 24 (%rsi), %r10 + movq (%rsi), %rax + movq 8(%rsi), %r8 + movq 16(%rsi), %r9 + movq 24(%rsi), %r10 - movq %rax, (%rdi) - movq %r8, 8 (%rdi) - movq %r9, 16 (%rdi) - movq %r10, 24 (%rdi) + movq %rax, (%rdi) + movq %r8, 8(%rdi) + movq %r9, 16(%rdi) + movq %r10, 24(%rdi) leaq 32(%rsi), %rsi leaq 32(%rdi), %rdi @@ -205,18 +205,18 @@ L(32loop): decl %ecx - movq (%rsi), %rax - movq 8 (%rsi), %r8 - movq 16 (%rsi), %r9 - movq 24 (%rsi), %r10 + movq (%rsi), %rax + movq 8(%rsi), %r8 + movq 16(%rsi), %r9 + movq 24(%rsi), %r10 - movq %rax, (%rdi) - movq %r8, 8 (%rdi) - movq %r9, 16 (%rdi) - movq %r10, 24 (%rdi) + movq %rax, (%rdi) + movq %r8, 8(%rdi) + movq %r9, 16(%rdi) + movq %r10, 24(%rdi) - leaq 32 (%rsi), %rsi - leaq 32 (%rdi), %rdi + leaq 32(%rsi), %rsi + leaq 32(%rdi), %rdi jnz L(32loop) @@ -229,9 +229,9 @@ L(32skip): movq %rdi, %rax #else - movq RETVAL (%rsp), %rax + movq RETVAL(%rsp), %rax jnz L(1) - + rep #endif retq /* exit */ @@ -245,11 +245,11 @@ L(32after): larger blocks are excluded when building for RTLD. */ -/* Handle large blocks smaller than 1/2 L1. */ +/* Handle blocks smaller than 1/2 L1. */ L(fasttry): /* first 1/2 L1 */ #ifndef NOT_IN_libc /* only up to this algorithm outside of libc.so */ - movq __x86_64_core_cache_size_half (%rip), %r11 + movq __x86_64_data_cache_size_half(%rip), %r11 cmpq %rdx, %r11 /* calculate the smaller of */ cmovaq %rdx, %r11 /* remaining bytes and 1/2 L1 */ #endif @@ -282,7 +282,7 @@ L(fastskip): movq %rdi, %rax #else - movq RETVAL (%rsp), %rax + movq RETVAL(%rsp), %rax jnz L(1) rep @@ -308,16 +308,16 @@ L(pre): /* 64-byte with prefetching */ shrq $6, %rcx jz L(preskip) - movq %r14, SAVE0 (%rsp) + movq %r14, SAVE0(%rsp) cfi_rel_offset (%r14, SAVE0) - movq %r13, SAVE1 (%rsp) + movq %r13, SAVE1(%rsp) cfi_rel_offset (%r13, SAVE1) - movq %r12, SAVE2 (%rsp) + movq %r12, SAVE2(%rsp) cfi_rel_offset (%r12, SAVE2) - movq %rbx, SAVE3 (%rsp) + movq %rbx, SAVE3(%rsp) cfi_rel_offset (%rbx, SAVE3) - cmpl $0, __x86_64_prefetchw (%rip) + cmpl $0, __x86_64_prefetchw(%rip) jz L(preloop) /* check if PREFETCHW OK */ .p2align 4 @@ -339,45 +339,45 @@ L(prewloop): /* cache-line in state M */ prefetcht0 0 + 896 (%rsi) prefetcht0 64 + 896 (%rsi) - movq %rax, (%rdi) - movq %rbx, 8 (%rdi) - movq %r9, 16 (%rdi) - movq %r10, 24 (%rdi) - movq %r11, 32 (%rdi) - movq %r12, 40 (%rdi) - movq %r13, 48 (%rdi) - movq %r14, 56 (%rdi) + movq %rax, (%rdi) + movq %rbx, 8(%rdi) + movq %r9, 16(%rdi) + movq %r10, 24(%rdi) + movq %r11, 32(%rdi) + movq %r12, 40(%rdi) + movq %r13, 48(%rdi) + movq %r14, 56(%rdi) - leaq 64 (%rsi), %rsi - leaq 64 (%rdi), %rdi + leaq 64(%rsi), %rsi + leaq 64(%rdi), %rdi jz L(prebail) decq %rcx - movq (%rsi), %rax - movq 8 (%rsi), %rbx - movq 16 (%rsi), %r9 - movq 24 (%rsi), %r10 - movq 32 (%rsi), %r11 - movq 40 (%rsi), %r12 - movq 48 (%rsi), %r13 - movq 56 (%rsi), %r14 - - movq %rax, (%rdi) - movq %rbx, 8 (%rdi) - movq %r9, 16 (%rdi) - movq %r10, 24 (%rdi) - movq %r11, 32 (%rdi) - movq %r12, 40 (%rdi) - movq %r13, 48 (%rdi) - movq %r14, 56 (%rdi) - - prefetchw 896 - 64 (%rdi) - prefetchw 896 - 0 (%rdi) - - leaq 64 (%rsi), %rsi - leaq 64 (%rdi), %rdi + movq (%rsi), %rax + movq 8(%rsi), %rbx + movq 16(%rsi), %r9 + movq 24(%rsi), %r10 + movq 32(%rsi), %r11 + movq 40(%rsi), %r12 + movq 48(%rsi), %r13 + movq 56(%rsi), %r14 + + movq %rax, (%rdi) + movq %rbx, 8(%rdi) + movq %r9, 16(%rdi) + movq %r10, 24(%rdi) + movq %r11, 32(%rdi) + movq %r12, 40(%rdi) + movq %r13, 48(%rdi) + movq %r14, 56(%rdi) + + prefetchw 896 - 64(%rdi) + prefetchw 896 - 0(%rdi) + + leaq 64(%rsi), %rsi + leaq 64(%rdi), %rdi jnz L(prewloop) jmp L(prebail) @@ -389,26 +389,26 @@ L(prewloop): /* cache-line in state M */ L(preloop): /* cache-line in state E */ decq %rcx - movq (%rsi), %rax - movq 8 (%rsi), %rbx - movq 16 (%rsi), %r9 - movq 24 (%rsi), %r10 - movq 32 (%rsi), %r11 - movq 40 (%rsi), %r12 - movq 48 (%rsi), %r13 - movq 56 (%rsi), %r14 - - prefetcht0 896 + 0 (%rsi) - prefetcht0 896 + 64 (%rsi) - - movq %rax, (%rdi) - movq %rbx, 8 (%rdi) - movq %r9, 16 (%rdi) - movq %r10, 24 (%rdi) - movq %r11, 32 (%rdi) - movq %r12, 40 (%rdi) - movq %r13, 48 (%rdi) - movq %r14, 56 (%rdi) + movq (%rsi), %rax + movq 8(%rsi), %rbx + movq 16(%rsi), %r9 + movq 24(%rsi), %r10 + movq 32(%rsi), %r11 + movq 40(%rsi), %r12 + movq 48(%rsi), %r13 + movq 56(%rsi), %r14 + + prefetcht0 896 + 0(%rsi) + prefetcht0 896 + 64(%rsi) + + movq %rax, (%rdi) + movq %rbx, 8(%rdi) + movq %r9, 16(%rdi) + movq %r10, 24(%rdi) + movq %r11, 32(%rdi) + movq %r12, 40(%rdi) + movq %r13, 48(%rdi) + movq %r14, 56(%rdi) leaq 64 (%rsi), %rsi leaq 64 (%rdi), %rdi @@ -417,40 +417,40 @@ L(preloop): /* cache-line in state E */ decq %rcx - movq (%rsi), %rax - movq 8 (%rsi), %rbx - movq 16 (%rsi), %r9 - movq 24 (%rsi), %r10 - movq 32 (%rsi), %r11 - movq 40 (%rsi), %r12 - movq 48 (%rsi), %r13 - movq 56 (%rsi), %r14 - - prefetcht0 896 - 64 (%rdi) - prefetcht0 896 - 0 (%rdi) - - movq %rax, (%rdi) - movq %rbx, 8 (%rdi) - movq %r9, 16 (%rdi) - movq %r10, 24 (%rdi) - movq %r11, 32 (%rdi) - movq %r12, 40 (%rdi) - movq %r13, 48 (%rdi) - movq %r14, 56 (%rdi) - - leaq 64 (%rsi), %rsi - leaq 64 (%rdi), %rdi + movq (%rsi), %rax + movq 8(%rsi), %rbx + movq 16(%rsi), %r9 + movq 24(%rsi), %r10 + movq 32(%rsi), %r11 + movq 40(%rsi), %r12 + movq 48(%rsi), %r13 + movq 56(%rsi), %r14 + + prefetcht0 896 - 64(%rdi) + prefetcht0 896 - 0(%rdi) + + movq %rax, (%rdi) + movq %rbx, 8(%rdi) + movq %r9, 16(%rdi) + movq %r10, 24(%rdi) + movq %r11, 32(%rdi) + movq %r12, 40(%rdi) + movq %r13, 48(%rdi) + movq %r14, 56(%rdi) + + leaq 64(%rsi), %rsi + leaq 64(%rdi), %rdi jnz L(preloop) L(prebail): - movq SAVE3 (%rsp), %rbx + movq SAVE3(%rsp), %rbx cfi_restore (%rbx) - movq SAVE2 (%rsp), %r12 + movq SAVE2(%rsp), %r12 cfi_restore (%r12) - movq SAVE1 (%rsp), %r13 + movq SAVE1(%rsp), %r13 cfi_restore (%r13) - movq SAVE0 (%rsp), %r14 + movq SAVE0(%rsp), %r14 cfi_restore (%r14) /* .p2align 4 */ @@ -466,7 +466,7 @@ L(preskip): movq %rdi, %rax #else - movq RETVAL (%rsp), %rax + movq RETVAL(%rsp), %rax jnz L(1) rep @@ -477,7 +477,7 @@ L(preskip): L(preafter): -/* Loop to handle huge blocks. */ +/* Handle huge blocks. */ L(NTtry): @@ -486,69 +486,69 @@ L(NT): /* non-temporal 128-byte */ shrq $7, %rcx jz L(NTskip) - movq %r14, SAVE0 (%rsp) + movq %r14, SAVE0(%rsp) cfi_rel_offset (%r14, SAVE0) - movq %r13, SAVE1 (%rsp) + movq %r13, SAVE1(%rsp) cfi_rel_offset (%r13, SAVE1) - movq %r12, SAVE2 (%rsp) + movq %r12, SAVE2(%rsp) cfi_rel_offset (%r12, SAVE2) .p2align 4 L(NTloop): - prefetchnta 768 (%rsi) - prefetchnta 832 (%rsi) + prefetchnta 768(%rsi) + prefetchnta 832(%rsi) decq %rcx - movq (%rsi), %rax - movq 8 (%rsi), %r8 - movq 16 (%rsi), %r9 - movq 24 (%rsi), %r10 - movq 32 (%rsi), %r11 - movq 40 (%rsi), %r12 - movq 48 (%rsi), %r13 - movq 56 (%rsi), %r14 - - movntiq %rax, (%rdi) - movntiq %r8, 8 (%rdi) - movntiq %r9, 16 (%rdi) - movntiq %r10, 24 (%rdi) - movntiq %r11, 32 (%rdi) - movntiq %r12, 40 (%rdi) - movntiq %r13, 48 (%rdi) - movntiq %r14, 56 (%rdi) - - movq 64 (%rsi), %rax - movq 72 (%rsi), %r8 - movq 80 (%rsi), %r9 - movq 88 (%rsi), %r10 - movq 96 (%rsi), %r11 - movq 104 (%rsi), %r12 - movq 112 (%rsi), %r13 - movq 120 (%rsi), %r14 - - movntiq %rax, 64 (%rdi) - movntiq %r8, 72 (%rdi) - movntiq %r9, 80 (%rdi) - movntiq %r10, 88 (%rdi) - movntiq %r11, 96 (%rdi) - movntiq %r12, 104 (%rdi) - movntiq %r13, 112 (%rdi) - movntiq %r14, 120 (%rdi) - - leaq 128 (%rsi), %rsi - leaq 128 (%rdi), %rdi + movq (%rsi), %rax + movq 8(%rsi), %r8 + movq 16(%rsi), %r9 + movq 24(%rsi), %r10 + movq 32(%rsi), %r11 + movq 40(%rsi), %r12 + movq 48(%rsi), %r13 + movq 56(%rsi), %r14 + + movntiq %rax, (%rdi) + movntiq %r8, 8(%rdi) + movntiq %r9, 16(%rdi) + movntiq %r10, 24(%rdi) + movntiq %r11, 32(%rdi) + movntiq %r12, 40(%rdi) + movntiq %r13, 48(%rdi) + movntiq %r14, 56(%rdi) + + movq 64(%rsi), %rax + movq 72(%rsi), %r8 + movq 80(%rsi), %r9 + movq 88(%rsi), %r10 + movq 96(%rsi), %r11 + movq 104(%rsi), %r12 + movq 112(%rsi), %r13 + movq 120(%rsi), %r14 + + movntiq %rax, 64(%rdi) + movntiq %r8, 72(%rdi) + movntiq %r9, 80(%rdi) + movntiq %r10, 88(%rdi) + movntiq %r11, 96(%rdi) + movntiq %r12, 104(%rdi) + movntiq %r13, 112(%rdi) + movntiq %r14, 120(%rdi) + + leaq 128(%rsi), %rsi + leaq 128(%rdi), %rdi jnz L(NTloop) sfence /* serialize memory stores */ - movq SAVE2 (%rsp), %r12 + movq SAVE2(%rsp), %r12 cfi_restore (%r12) - movq SAVE1 (%rsp), %r13 + movq SAVE1(%rsp), %r13 cfi_restore (%r13) - movq SAVE0 (%rsp), %r14 + movq SAVE0(%rsp), %r14 cfi_restore (%r14) L(NTskip): @@ -558,7 +558,7 @@ L(NTskip): movq %rdi, %rax #else - movq RETVAL (%rsp), %rax + movq RETVAL(%rsp), %rax jnz L(1) rep |