Merge "Bug 3330205 Put blanks and zeroes in const area"
diff --git a/libc/arch-x86/include/endian.h b/libc/arch-x86/include/endian.h
index ad37919..4a70536 100644
--- a/libc/arch-x86/include/endian.h
+++ b/libc/arch-x86/include/endian.h
@@ -31,14 +31,14 @@
#if defined(_KERNEL) && !defined(I386_CPU)
#define __swap32md(x) ({ \
- u_int32_t __swap32md_x = (x); \
+ uint32_t __swap32md_x = (x); \
\
__asm ("bswap %1" : "+r" (__swap32md_x)); \
__swap32md_x; \
})
#else
#define __swap32md(x) ({ \
- u_int32_t __swap32md_x = (x); \
+ uint32_t __swap32md_x = (x); \
\
__asm ("rorw $8, %w1; rorl $16, %1; rorw $8, %w1" : \
"+r" (__swap32md_x)); \
@@ -47,13 +47,13 @@
#endif /* _KERNEL && !I386_CPU */
#define __swap64md(x) ({ \
- u_int64_t __swap64md_x = (x); \
+ uint64_t __swap64md_x = (x); \
\
- (u_int64_t)__swap32md(__swap64md_x >> 32) | \
- (u_int64_t)__swap32md(__swap64md_x & 0xffffffff) << 32; \
+ (uint64_t)__swap32md(__swap64md_x >> 32) | \
+ (uint64_t)__swap32md(__swap64md_x & 0xffffffff) << 32; \
})
#define __swap16md(x) ({ \
- u_int16_t __swap16md_x = (x); \
+ uint16_t __swap16md_x = (x); \
\
__asm ("rorw $8, %w1" : "+r" (__swap16md_x)); \
__swap16md_x; \
diff --git a/libc/arch-x86/include/machine/_types.h b/libc/arch-x86/include/machine/_types.h
index be4f6e4..e9280a5 100644
--- a/libc/arch-x86/include/machine/_types.h
+++ b/libc/arch-x86/include/machine/_types.h
@@ -36,8 +36,8 @@
#define _I386__TYPES_H_
/* the kernel defines size_t as unsigned int, but g++ wants it to be unsigned long */
-#ifndef _SIZE_T
-# define _SIZE_T
+#ifndef _SIZE_T_DEFINED_
+# define _SIZE_T_DEFINED_
# ifdef ANDROID
typedef unsigned int size_t;
# else
@@ -54,9 +54,6 @@
typedef long ptrdiff_t;
#endif
-#define _OFF_T_DEFINED_
-#define _SIZE_T_DEFINED_
-
#include <linux/types.h>
/* 7.18.1.1 Exact-width integer types */
diff --git a/libc/bionic/md5.c b/libc/bionic/md5.c
index 087786f..1117c3b 100644
--- a/libc/bionic/md5.c
+++ b/libc/bionic/md5.c
@@ -237,7 +237,7 @@
void
MD5_Final (void *res, struct md5 *m)
{
- static unsigned char zeros[72];
+ unsigned char zeros[72];
unsigned offset = (m->sz[0] / 8) % 64;
unsigned int dstart = (120 - offset - 1) % 64 + 1;
diff --git a/libc/netbsd/net/getaddrinfo.c b/libc/netbsd/net/getaddrinfo.c
index 778f44c..993c934 100644
--- a/libc/netbsd/net/getaddrinfo.c
+++ b/libc/netbsd/net/getaddrinfo.c
@@ -1525,9 +1525,13 @@
#define IN6_IS_ADDR_6TO4(a) \
(((a)->s6_addr[0] == 0x20) && ((a)->s6_addr[1] == 0x02))
+/* 6bone testing address area (3ffe::/16), deprecated in RFC 3701. */
+#define IN6_IS_ADDR_6BONE(a) \
+ (((a)->s6_addr[0] == 0x3f) && ((a)->s6_addr[1] == 0xfe))
+
/*
* Get the label for a given IPv4/IPv6 address.
- * RFC 3484, section 2.1, plus Teredo added in with label 5.
+ * RFC 3484, section 2.1, plus changes from draft-ietf-6man-rfc3484-revise-01.
*/
/*ARGSUSED*/
@@ -1535,19 +1539,27 @@
_get_label(const struct sockaddr *addr)
{
if (addr->sa_family == AF_INET) {
- return 4;
+ return 3;
} else if (addr->sa_family == AF_INET6) {
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr;
if (IN6_IS_ADDR_LOOPBACK(&addr6->sin6_addr)) {
return 0;
- } else if (IN6_IS_ADDR_V4COMPAT(&addr6->sin6_addr)) {
+ } else if (IN6_IS_ADDR_ULA(&addr6->sin6_addr)) {
+ return 1;
+ } else if (IN6_IS_ADDR_V4MAPPED(&addr6->sin6_addr)) {
return 3;
+ } else if (IN6_IS_ADDR_6TO4(&addr6->sin6_addr)) {
+ return 4;
} else if (IN6_IS_ADDR_TEREDO(&addr6->sin6_addr)) {
return 5;
- } else if (IN6_IS_ADDR_6TO4(&addr6->sin6_addr)) {
- return 2;
+ } else if (IN6_IS_ADDR_V4COMPAT(&addr6->sin6_addr)) {
+ return 10;
+ } else if (IN6_IS_ADDR_SITELOCAL(&addr6->sin6_addr)) {
+ return 11;
+ } else if (IN6_IS_ADDR_6BONE(&addr6->sin6_addr)) {
+ return 12;
} else {
- return 1;
+ return 2;
}
} else {
/*
@@ -1560,7 +1572,7 @@
/*
* Get the precedence for a given IPv4/IPv6 address.
- * RFC 3484, section 2.1, plus Teredo added in with precedence 25.
+ * RFC 3484, section 2.1, plus changes from draft-ietf-6man-rfc3484-revise-01.
*/
/*ARGSUSED*/
@@ -1568,22 +1580,28 @@
_get_precedence(const struct sockaddr *addr)
{
if (addr->sa_family == AF_INET) {
- return 10;
+ return 30;
} else if (addr->sa_family == AF_INET6) {
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr;
if (IN6_IS_ADDR_LOOPBACK(&addr6->sin6_addr)) {
+ return 60;
+ } else if (IN6_IS_ADDR_ULA(&addr6->sin6_addr)) {
return 50;
- } else if (IN6_IS_ADDR_V4COMPAT(&addr6->sin6_addr)) {
+ } else if (IN6_IS_ADDR_V4MAPPED(&addr6->sin6_addr)) {
+ return 30;
+ } else if (IN6_IS_ADDR_6TO4(&addr6->sin6_addr)) {
return 20;
} else if (IN6_IS_ADDR_TEREDO(&addr6->sin6_addr)) {
- return 25;
- } else if (IN6_IS_ADDR_6TO4(&addr6->sin6_addr)) {
- return 30;
+ return 10;
+ } else if (IN6_IS_ADDR_V4COMPAT(&addr6->sin6_addr) ||
+ IN6_IS_ADDR_SITELOCAL(&addr6->sin6_addr) ||
+ IN6_IS_ADDR_6BONE(&addr6->sin6_addr)) {
+ return 1;
} else {
return 40;
}
} else {
- return 5;
+ return 1;
}
}
diff --git a/libc/stdio/vfprintf.c b/libc/stdio/vfprintf.c
index 5a8aa0a..9c36b79 100644
--- a/libc/stdio/vfprintf.c
+++ b/libc/stdio/vfprintf.c
@@ -1219,7 +1219,6 @@
{
int mode, dsgn;
char *digits, *bp, *rve;
- static char temp[64];
if (ch == 'f') {
mode = 3; /* ndigits after the decimal point */
diff --git a/libc/tzcode/strptime.c b/libc/tzcode/strptime.c
index 1f481c9..0567aa4 100644
--- a/libc/tzcode/strptime.c
+++ b/libc/tzcode/strptime.c
@@ -89,29 +89,31 @@
#define _LEGAL_ALT(x) { if (alt_format & ~(x)) return (0); }
+struct century_relyear {
+ int century;
+ int relyear;
+};
static int _conv_num(const unsigned char **, int *, int, int);
-static unsigned char *_strptime(const unsigned char *, const char *, struct tm *, int);
+static unsigned char *_strptime(const unsigned char *, const char *, struct tm *,
+ struct century_relyear *);
char *
strptime(const char *buf, const char *fmt, struct tm *tm)
{
- return (char*)(_strptime((const unsigned char*)buf, fmt, tm, 1));
+ struct century_relyear cr;
+ cr.century = TM_YEAR_BASE;
+ cr.relyear = -1;
+ return (char*)(_strptime((const unsigned char*)buf, fmt, tm, &cr));
}
static unsigned char *
-_strptime(const unsigned char *buf, const char *fmt, struct tm *tm, int initialize)
+_strptime(const unsigned char *buf, const char *fmt, struct tm *tm, struct century_relyear *cr)
{
unsigned char c;
const unsigned char *bp;
size_t len = 0;
int alt_format, i;
- static int century, relyear;
-
- if (initialize) {
- century = TM_YEAR_BASE;
- relyear = -1;
- }
bp = (unsigned char *)buf;
while ((c = *fmt) != '\0') {
@@ -158,43 +160,43 @@
*/
case 'c': /* Date and time, using the locale's format. */
_LEGAL_ALT(_ALT_E);
- if (!(bp = _strptime(bp, _ctloc(d_t_fmt), tm, 0)))
+ if (!(bp = _strptime(bp, _ctloc(d_t_fmt), tm, cr)))
return (NULL);
break;
case 'D': /* The date as "%m/%d/%y". */
_LEGAL_ALT(0);
- if (!(bp = _strptime(bp, "%m/%d/%y", tm, 0)))
+ if (!(bp = _strptime(bp, "%m/%d/%y", tm, cr)))
return (NULL);
break;
case 'R': /* The time as "%H:%M". */
_LEGAL_ALT(0);
- if (!(bp = _strptime(bp, "%H:%M", tm, 0)))
+ if (!(bp = _strptime(bp, "%H:%M", tm, cr)))
return (NULL);
break;
case 'r': /* The time as "%I:%M:%S %p". */
_LEGAL_ALT(0);
- if (!(bp = _strptime(bp, "%I:%M:%S %p", tm, 0)))
+ if (!(bp = _strptime(bp, "%I:%M:%S %p", tm, cr)))
return (NULL);
break;
case 'T': /* The time as "%H:%M:%S". */
_LEGAL_ALT(0);
- if (!(bp = _strptime(bp, "%H:%M:%S", tm, 0)))
+ if (!(bp = _strptime(bp, "%H:%M:%S", tm, cr)))
return (NULL);
break;
case 'X': /* The time, using the locale's format. */
_LEGAL_ALT(_ALT_E);
- if (!(bp = _strptime(bp, _ctloc(t_fmt), tm, 0)))
+ if (!(bp = _strptime(bp, _ctloc(t_fmt), tm, cr)))
return (NULL);
break;
case 'x': /* The date, using the locale's format. */
_LEGAL_ALT(_ALT_E);
- if (!(bp = _strptime(bp, _ctloc(d_fmt), tm, 0)))
+ if (!(bp = _strptime(bp, _ctloc(d_fmt), tm, cr)))
return (NULL);
break;
@@ -253,7 +255,7 @@
if (!(_conv_num(&bp, &i, 0, 99)))
return (NULL);
- century = i * 100;
+ cr->century = i * 100;
break;
case 'd': /* The day of month. */
@@ -359,13 +361,13 @@
if (!(_conv_num(&bp, &i, 0, 9999)))
return (NULL);
- relyear = -1;
+ cr->relyear = -1;
tm->tm_year = i - TM_YEAR_BASE;
break;
case 'y': /* The year within the century (2 digits). */
_LEGAL_ALT(_ALT_E | _ALT_O);
- if (!(_conv_num(&bp, &relyear, 0, 99)))
+ if (!(_conv_num(&bp, &cr->relyear, 0, 99)))
return (NULL);
break;
@@ -391,14 +393,14 @@
* We need to evaluate the two digit year spec (%y)
* last as we can get a century spec (%C) at any time.
*/
- if (relyear != -1) {
- if (century == TM_YEAR_BASE) {
- if (relyear <= 68)
- tm->tm_year = relyear + 2000 - TM_YEAR_BASE;
+ if (cr->relyear != -1) {
+ if (cr->century == TM_YEAR_BASE) {
+ if (cr->relyear <= 68)
+ tm->tm_year = cr->relyear + 2000 - TM_YEAR_BASE;
else
- tm->tm_year = relyear + 1900 - TM_YEAR_BASE;
+ tm->tm_year = cr->relyear + 1900 - TM_YEAR_BASE;
} else {
- tm->tm_year = relyear + century - TM_YEAR_BASE;
+ tm->tm_year = cr->relyear + cr->century - TM_YEAR_BASE;
}
}