Merge "Sync with some upstream OpenBSD #include cleanup."
diff --git a/libc/Android.mk b/libc/Android.mk
index cb55fd4..dae254f 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -288,7 +288,6 @@
     upstream-netbsd/lib/libc/stdlib/div.c \
     upstream-netbsd/lib/libc/stdlib/drand48.c \
     upstream-netbsd/lib/libc/stdlib/erand48.c \
-    upstream-netbsd/lib/libc/stdlib/insque.c \
     upstream-netbsd/lib/libc/stdlib/jrand48.c \
     upstream-netbsd/lib/libc/stdlib/ldiv.c \
     upstream-netbsd/lib/libc/stdlib/lldiv.c \
@@ -297,14 +296,12 @@
     upstream-netbsd/lib/libc/stdlib/nrand48.c \
     upstream-netbsd/lib/libc/stdlib/_rand48.c \
     upstream-netbsd/lib/libc/stdlib/rand_r.c \
-    upstream-netbsd/lib/libc/stdlib/remque.c \
     upstream-netbsd/lib/libc/stdlib/seed48.c \
     upstream-netbsd/lib/libc/stdlib/srand48.c \
     upstream-netbsd/lib/libc/string/memccpy.c \
     upstream-netbsd/lib/libc/string/strcasestr.c \
     upstream-netbsd/lib/libc/string/strcoll.c \
     upstream-netbsd/lib/libc/string/strxfrm.c \
-    upstream-netbsd/lib/libc/unistd/killpg.c \
 
 libc_upstream_openbsd_gdtoa_src_files := \
     upstream-openbsd/android/gdtoa_support.cpp \
@@ -334,6 +331,7 @@
     upstream-openbsd/lib/libc/gdtoa/strtorQ.c \
 
 libc_upstream_openbsd_src_files := \
+    upstream-openbsd/lib/libc/compat-43/killpg.c \
     upstream-openbsd/lib/libc/crypt/arc4random.c \
     upstream-openbsd/lib/libc/crypt/arc4random_uniform.c \
     upstream-openbsd/lib/libc/gen/alarm.c \
@@ -480,7 +478,9 @@
     upstream-openbsd/lib/libc/stdlib/atoll.c \
     upstream-openbsd/lib/libc/stdlib/exit.c \
     upstream-openbsd/lib/libc/stdlib/getenv.c \
+    upstream-openbsd/lib/libc/stdlib/insque.c \
     upstream-openbsd/lib/libc/stdlib/lsearch.c \
+    upstream-openbsd/lib/libc/stdlib/remque.c \
     upstream-openbsd/lib/libc/stdlib/setenv.c \
     upstream-openbsd/lib/libc/stdlib/strtoimax.c \
     upstream-openbsd/lib/libc/stdlib/strtol.c \
diff --git a/libc/upstream-netbsd/lib/libc/unistd/killpg.c b/libc/upstream-openbsd/lib/libc/compat-43/killpg.c
similarity index 80%
rename from libc/upstream-netbsd/lib/libc/unistd/killpg.c
rename to libc/upstream-openbsd/lib/libc/compat-43/killpg.c
index ceac3f4..75b1ad9 100644
--- a/libc/upstream-netbsd/lib/libc/unistd/killpg.c
+++ b/libc/upstream-openbsd/lib/libc/compat-43/killpg.c
@@ -1,8 +1,6 @@
-/*	$NetBSD: killpg.c,v 1.8 2003/08/07 16:42:39 agc Exp $	*/
-
 /*
- * Copyright (c) 1989, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,15 +27,6 @@
  * SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)killpg.c	8.1 (Berkeley) 6/2/93";
-#else
-__RCSID("$NetBSD: killpg.c,v 1.8 2003/08/07 16:42:39 agc Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
-
 #include <sys/types.h>
 #include <signal.h>
 #include <errno.h>
diff --git a/libc/upstream-netbsd/lib/libc/stdlib/insque.c b/libc/upstream-openbsd/lib/libc/stdlib/insque.c
similarity index 81%
rename from libc/upstream-netbsd/lib/libc/stdlib/insque.c
rename to libc/upstream-openbsd/lib/libc/stdlib/insque.c
index 09020ae..590ff83 100644
--- a/libc/upstream-netbsd/lib/libc/stdlib/insque.c
+++ b/libc/upstream-openbsd/lib/libc/stdlib/insque.c
@@ -1,7 +1,9 @@
+/*	$OpenBSD: insque.c,v 1.3 2014/08/15 04:14:36 guenther Exp $	*/
+
 /*
  *  Copyright (c) 1993 John Brezak
  *  All rights reserved.
- *
+ * 
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
  *  are met:
@@ -12,7 +14,7 @@
  *     documentation and/or other materials provided with the distribution.
  *  3. The name of the author may be used to endorse or promote products
  *     derived from this software without specific prior written permission.
- *
+ * 
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -26,12 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: insque.c,v 1.3 2012/06/25 22:32:45 abs Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include <assert.h>
+#include <stdlib.h>
 #include <search.h>
 
 struct qelem {
@@ -42,17 +39,16 @@
 void
 insque(void *entry, void *pred)
 {
-	struct qelem *e = (struct qelem *) entry;
-	struct qelem *p = (struct qelem *) pred;
+	struct qelem *e = entry;
+	struct qelem *p = pred;
 
-	_DIAGASSERT(e != 0);
-
-	e->q_back = p;
-	if (p) {
+	if (p == NULL)
+		e->q_forw = e->q_back = NULL;
+	else {
 		e->q_forw = p->q_forw;
-		if (p->q_forw)
+		e->q_back = p;
+		if (p->q_forw != NULL)
 			p->q_forw->q_back = e;
 		p->q_forw = e;
-	} else
-		e->q_forw = 0;
+	}
 }
diff --git a/libc/upstream-netbsd/lib/libc/stdlib/remque.c b/libc/upstream-openbsd/lib/libc/stdlib/remque.c
similarity index 84%
rename from libc/upstream-netbsd/lib/libc/stdlib/remque.c
rename to libc/upstream-openbsd/lib/libc/stdlib/remque.c
index 6060ad8..71b74b2 100644
--- a/libc/upstream-netbsd/lib/libc/stdlib/remque.c
+++ b/libc/upstream-openbsd/lib/libc/stdlib/remque.c
@@ -1,7 +1,9 @@
+/*	$OpenBSD: remque.c,v 1.3 2014/08/15 04:14:36 guenther Exp $	*/
+
 /*
  *  Copyright (c) 1993 John Brezak
  *  All rights reserved.
- *
+ * 
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
  *  are met:
@@ -12,7 +14,7 @@
  *     documentation and/or other materials provided with the distribution.
  *  3. The name of the author may be used to endorse or promote products
  *     derived from this software without specific prior written permission.
- *
+ * 
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -26,12 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: remque.c,v 1.3 2012/06/25 22:32:45 abs Exp $");
-#endif /* LIBC_SCCS and not lint */
-
-#include <assert.h>
+#include <stdlib.h>
 #include <search.h>
 
 struct qelem {
@@ -42,12 +39,10 @@
 void
 remque(void *element)
 {
-	struct qelem *e = (struct qelem *) element;
+	struct qelem *e = element;
 
-	_DIAGASSERT(e != 0);
-
-	if (e->q_forw)
+	if (e->q_forw != NULL)
 		e->q_forw->q_back = e->q_back;
-	if (e->q_back)
+	if (e->q_back != NULL)
 		e->q_back->q_forw = e->q_forw;
 }