Refresh toolbox.

Use more upstream NetBSD, and update those things that were already NetBSD.

Note that unlike bionic, the upstream-netbsd directory isn't pristine; we have
changes marked by __ANDROID__.

Bug: 16493461
Change-Id: I99762bfe02caa0945ea4a184670888a4b5435a1d
diff --git a/toolbox/bsd-compatibility.h b/toolbox/bsd-compatibility.h
index abc3064..9c6c34a 100644
--- a/toolbox/bsd-compatibility.h
+++ b/toolbox/bsd-compatibility.h
@@ -26,6 +26,7 @@
  * SUCH DAMAGE.
  */
 
+#include <stdbool.h>
 #include <sys/types.h>
 
 /* We want chown to support user.group as well as user:group. */
@@ -34,8 +35,58 @@
 /* We don't localize /system/bin! */
 #define WITHOUT_NLS
 
+// NetBSD uses _DIAGASSERT to null-check arguments and the like.
+#include <assert.h>
+#define _DIAGASSERT(e) ((e) ? (void) 0 : __assert2(__FILE__, __LINE__, __func__, #e))
+
+// TODO: update our <sys/cdefs.h> to support this properly.
+#define __type_fit(t, a) (0 == 0)
+
+// TODO: should this be in our <sys/cdefs.h>?
+#define __arraycount(a) (sizeof(a) / sizeof(a[0]))
+
+// This at least matches GNU dd(1) behavior.
+#define SIGINFO SIGUSR1
+
+#define S_ISWHT(x) false
+
+// TODO: should this be in bionic? (glibc does this, even though it's not quite right.)
+#define O_RSYNC O_SYNC
+
 __BEGIN_DECLS
 
-extern int uid_from_user(const char* name, uid_t* uid);
+/* From NetBSD <grp.h> and <pwd.h>. */
+char* group_from_gid(gid_t gid, int noname);
+int uid_from_user(const char* name, uid_t* uid);
+char* user_from_uid(uid_t uid, int noname);
+
+/* From NetBSD <stdlib.h>. */
+#define HN_DECIMAL              0x01
+#define HN_NOSPACE              0x02
+#define HN_B                    0x04
+#define HN_DIVISOR_1000         0x08
+#define HN_GETSCALE             0x10
+#define HN_AUTOSCALE            0x20
+int	humanize_number(char *, size_t, int64_t, const char *, int, int);
+int	dehumanize_number(const char *, int64_t *);
+char	*getbsize(int *, long *);
+long long strsuftoll(const char *, const char *, long long, long long);
+long long strsuftollx(const char *, const char *, long long, long long,
+			char *, size_t);
+
+/* From NetBSD <string.h>. */
+void strmode(mode_t, char*);
+
+/* From NetBSD <sys/param.h>. */
+#define MAXBSIZE 65536
+
+/* From NetBSD <sys/stat.h>. */
+#define DEFFILEMODE (S_IRUSR | S_IWUSR)
+
+/* From NetBSD <unistd.h>. */
+void	swab(const void * __restrict, void * __restrict, ssize_t);
+
+/* From NetBSD <util.h>. */
+int		raise_default_signal(int);
 
 __END_DECLS