Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/__lctrans.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/__lctrans.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/__lctrans.c	(revision 387)
@@ -8,7 +8,5 @@
 }
 
-#ifndef __c2__
 weak_alias(dummy, __lctrans_impl);
-#endif
 
 const char *__lctrans(const char *msg, const struct __locale_map *lm)
Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/__mo_lookup.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/__mo_lookup.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/__mo_lookup.c	(revision 387)
@@ -4,5 +4,5 @@
 static inline uint32_t swapc(uint32_t x, int c)
 {
-	return c ? x>>24 | x>>8&0xff00 | x<<8&0xff0000 | x<<24 : x;
+	return c ? (x>>24) | (x>>8&0xff00) | (x<<8&0xff0000) | (x<<24) : x;
 }
 
Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/iconv.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/iconv.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/iconv.c	(revision 387)
@@ -136,5 +136,5 @@
 {
 	e &= 3;
-	return s[e]+0U<<24 | s[e^1]<<16 | s[e^2]<<8 | s[e^3];
+	return (s[e]+0U)<<24 | s[e^1]<<16 | s[e^2]<<8 | s[e^3];
 }
 
@@ -156,5 +156,5 @@
 	unsigned x = c - 128 - map[-1];
 	x = legacy_chars[ map[x*5/4]>>2*x%8 |
-		map[x*5/4+1]<<8-2*x%8 & 1023 ];
+		(map[x*5/4+1]<<(8-2*x%8) & 1023) ];
 	return x ? x : c;
 }
@@ -348,5 +348,5 @@
 				c += (0xa1-0x81);
 				d += 0xa1;
-				if (c >= 93 || c>=0xc6-0x81 && d>0x52)
+				if (c >= 93 || (c>=0xc6-0x81 && d>0x52))
 					goto ilseq;
 				if (d-'A'<26) d = d-'A';
Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/locale_map.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/locale_map.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/locale_map.c	(revision 387)
@@ -36,7 +36,7 @@
 
 	if (!*val) {
-		(val = getenv("LC_ALL")) && *val ||
-		(val = getenv(envvars[cat])) && *val ||
-		(val = getenv("LANG")) && *val ||
+		((val = getenv("LC_ALL")) && *val) ||
+		((val = getenv(envvars[cat])) && *val) ||
+		((val = getenv("LANG")) && *val) ||
 		(val = "C.UTF-8");
 	}
Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/malloc/memalign.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/malloc/memalign.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/malloc/memalign.c	(revision 387)
@@ -46,8 +46,8 @@
 	footer = ((size_t *)end)[-2];
 
-	((size_t *)mem)[-1] = header&7 | new-mem;
-	((size_t *)new)[-2] = footer&7 | new-mem;
-	((size_t *)new)[-1] = header&7 | end-new;
-	((size_t *)end)[-2] = footer&7 | end-new;
+	((size_t *)mem)[-1] = (header&7) | new-mem;
+	((size_t *)new)[-2] = (footer&7) | new-mem;
+	((size_t *)new)[-1] = (header&7) | end-new;
+	((size_t *)end)[-2] = (footer&7) | end-new;
 
 	free(mem);
Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/math/fma.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/math/fma.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/math/fma.c	(revision 387)
@@ -70,5 +70,5 @@
 		if (d < 64) {
 			zlo = nz.m<<d;
-			zhi = nz.m>>64-d;
+			zhi = nz.m>>(64-d);
 		} else {
 			zlo = 0;
@@ -78,5 +78,5 @@
 			if (d == 0) {
 			} else if (d < 64) {
-				rlo = rhi<<64-d | rlo>>d | !!(rlo<<64-d);
+				rlo = rhi<<(64-d) | rlo>>d | !!(rlo<<(64-d));
 				rhi = rhi>>d;
 			} else {
@@ -91,5 +91,5 @@
 			zlo = nz.m;
 		} else if (d < 64) {
-			zlo = nz.m>>d | !!(nz.m<<64-d);
+			zlo = nz.m>>d | !!(nz.m<<(64-d));
 		} else {
 			zlo = 1;
@@ -123,5 +123,5 @@
 		d = a_clz_64(rhi)-1;
 		/* note: d > 0 */
-		rhi = rhi<<d | rlo>>64-d | !!(rlo<<d);
+		rhi = rhi<<d | rlo>>(64-d) | !!(rlo<<d);
 	} else if (rlo) {
 		d = a_clz_64(rlo)-1;
@@ -174,5 +174,5 @@
 			/* only round once when scaled */
 			d = 10;
-			i = ( rhi>>d | !!(rhi<<64-d) ) << d;
+			i = ( rhi>>d | !!(rhi<<(64-d)) ) << d;
 			if (sign)
 				i = -i;
Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/network/lookup_name.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/network/lookup_name.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/network/lookup_name.c	(revision 387)
@@ -11,4 +11,5 @@
 #include <pthread.h>
 #include <errno.h>
+#include <resolv.h>
 #include "lookup.h"
 #include "stdio_impl.h"
@@ -185,4 +186,8 @@
 	if (dots >= conf.ndots || name[l-1]=='.') *search = 0;
 
+	/* Strip final dot for canon, fail if multiple trailing dots. */
+	if (name[l-1]=='.') l--;
+	if (!l || name[l-1]=='.') return EAI_NONAME;
+
 	/* This can never happen; the caller already checked length. */
 	if (l >= 256) return EAI_NONAME;
@@ -311,5 +316,5 @@
 	if (!cnt && !(flags & AI_NUMERICHOST)) {
 		cnt = name_from_hosts(buf, canon, name, family);
-		if (!cnt) cnt = name_from_dns_search(buf, canon, name, family);
+		if (cnt<=0) cnt = name_from_dns_search(buf, canon, name, family);
 	}
 	if (cnt<=0) return cnt ? cnt : EAI_NONAME;
@@ -352,34 +357,51 @@
 	 * So far the label/precedence table cannot be customized. */
 	for (i=0; i<cnt; i++) {
+		int family = buf[i].family;
 		int key = 0;
-		struct sockaddr_in6 sa, da = {
+		struct sockaddr_in6 sa6 = { 0 }, da6 = {
 			.sin6_family = AF_INET6,
 			.sin6_scope_id = buf[i].scopeid,
 			.sin6_port = 65535
 		};
-		if (buf[i].family == AF_INET6) {
-			memcpy(da.sin6_addr.s6_addr, buf[i].addr, 16);
+		struct sockaddr_in sa4 = { 0 }, da4 = {
+			.sin_family = AF_INET,
+			.sin_port = 65535
+		};
+		void *sa, *da;
+		socklen_t salen, dalen;
+		if (family == AF_INET6) {
+			memcpy(da6.sin6_addr.s6_addr, buf[i].addr, 16);
+			da = &da6; dalen = sizeof da6;
+			sa = &sa6; salen = sizeof sa6;
 		} else {
-			memcpy(da.sin6_addr.s6_addr,
+			memcpy(sa6.sin6_addr.s6_addr,
 				"\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
-			memcpy(da.sin6_addr.s6_addr+12, buf[i].addr, 4);
-		}
-		const struct policy *dpolicy = policyof(&da.sin6_addr);
-		int dscope = scopeof(&da.sin6_addr);
+			memcpy(da6.sin6_addr.s6_addr+12, buf[i].addr, 4);
+			memcpy(da6.sin6_addr.s6_addr,
+				"\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
+			memcpy(da6.sin6_addr.s6_addr+12, buf[i].addr, 4);
+			memcpy(&da4.sin_addr, buf[i].addr, 4);
+			da = &da4; dalen = sizeof da4;
+			sa = &sa4; salen = sizeof sa4;
+		}
+		const struct policy *dpolicy = policyof(&da6.sin6_addr);
+		int dscope = scopeof(&da6.sin6_addr);
 		int dlabel = dpolicy->label;
 		int dprec = dpolicy->prec;
 		int prefixlen = 0;
-		int fd = socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP);
+		int fd = socket(family, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP);
 		if (fd >= 0) {
-			if (!connect(fd, (void *)&da, sizeof da)) {
+			if (!connect(fd, da, dalen)) {
 				key |= DAS_USABLE;
-				if (!getsockname(fd, (void *)&sa,
-				    &(socklen_t){sizeof sa})) {
-					if (dscope == scopeof(&sa.sin6_addr))
+				if (!getsockname(fd, sa, &salen)) {
+					if (family == AF_INET) memcpy(
+						sa6.sin6_addr.s6_addr+12,
+						&sa4.sin_addr, 4);
+					if (dscope == scopeof(&sa6.sin6_addr))
 						key |= DAS_MATCHINGSCOPE;
-					if (dlabel == labelof(&sa.sin6_addr))
+					if (dlabel == labelof(&sa6.sin6_addr))
 						key |= DAS_MATCHINGLABEL;
-					prefixlen = prefixmatch(&sa.sin6_addr,
-						&da.sin6_addr);
+					prefixlen = prefixmatch(&sa6.sin6_addr,
+						&da6.sin6_addr);
 				}
 			}
Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/process/vfork.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/process/vfork.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/process/vfork.c	(revision 387)
@@ -15,10 +15,3 @@
 }
 
-#ifndef __c2__
 weak_alias(__vfork, vfork);
-#else
-pid_t vfork(void)
-{
-	return __vfork();
-}
-#endif
Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/signal/sigaction.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/signal/sigaction.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/signal/sigaction.c	(revision 387)
@@ -61,10 +61,3 @@
 }
 
-#ifndef __c2__
 weak_alias(__sigaction, sigaction);
-#else
-int sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)
-{
-	return __sigaction(sig, sa, old);
-}
-#endif
Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/stdio/__stdio_write.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/stdio/__stdio_write.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/stdio/__stdio_write.c	(revision 387)
@@ -32,3 +32,4 @@
 		iov[0].iov_len -= cnt;
 	}
+	return -1;
 }
Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/stdlib/strtol.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/stdlib/strtol.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/stdlib/strtol.c	(revision 387)
@@ -57,11 +57,6 @@
 }
 
-#if defined(_MSC_VER) || defined(__c2__)
-weak_alias(musl_strtol, __strtol_internal);
-weak_alias(musl_strtoul, __strtoul_internal);
-#else
 weak_alias(strtol, __strtol_internal);
 weak_alias(strtoul, __strtoul_internal);
-#endif
 weak_alias(strtoll, __strtoll_internal);
 weak_alias(strtoull, __strtoull_internal);
Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/string/memrchr.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/string/memrchr.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/string/memrchr.c	(revision 387)
@@ -10,10 +10,3 @@
 }
 
-#ifndef __c2__
 weak_alias(__memrchr, memrchr);
-#else
-void *memrchr(const void *m, int c, size_t n)
-{
-	return __memrchr(m, c, n);
-}
-#endif
Index: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/string/strchrnul.c
===================================================================
--- asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/string/strchrnul.c	(revision 374)
+++ asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/string/strchrnul.c	(revision 387)
@@ -24,10 +24,3 @@
 }
 
-#ifndef __c2__
 weak_alias(__strchrnul, strchrnul);
-#else
-char *strchrnul(const char *s, int c)
-{
-	return __strchrnul(s, c);
-}
-#endif
