From e7785326e358a46d53203670106bb38236e26db4 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Wed, 30 Dec 2020 12:02:53 +0100
Subject: [PATCH] Add <endian.h>, which for now only includes <sys/endian.h>.

An <endian.h> header was recently approved by The Austin Group:
https://www.austingroupbugs.net/view.php?id=162

Add one now, mainly for dports. It will be further POSIXized later.
---
 gnu/lib/gcc47/libstdc++/config.h              |  2 +-
 gnu/lib/gcc80/libstdcxx/headers/config.h      |  2 +-
 .../binutils234/block1/libctf/config.h        |  2 +-
 include/Makefile                              |  5 ++-
 include/endian.h                              | 37 +++++++++++++++++++
 lib/libssh/config.h                           |  2 +-
 6 files changed, 44 insertions(+), 6 deletions(-)
 create mode 100644 include/endian.h

diff --git a/gnu/lib/gcc47/libstdc++/config.h b/gnu/lib/gcc47/libstdc++/config.h
index 0e6d5e1af4..4cded0a7ca 100644
--- a/gnu/lib/gcc47/libstdc++/config.h
+++ b/gnu/lib/gcc47/libstdc++/config.h
@@ -68,7 +68,7 @@
 #define HAVE_EIDRM 1
 
 /* Define to 1 if you have the <endian.h> header file. */
-/* #undef HAVE_ENDIAN_H */
+#define HAVE_ENDIAN_H 1
 
 /* Define if ENODATA exists. */
 /* #undef HAVE_ENODATA */
diff --git a/gnu/lib/gcc80/libstdcxx/headers/config.h b/gnu/lib/gcc80/libstdcxx/headers/config.h
index c4f8965114..b7cb70489a 100644
--- a/gnu/lib/gcc80/libstdcxx/headers/config.h
+++ b/gnu/lib/gcc80/libstdcxx/headers/config.h
@@ -77,7 +77,7 @@
 #define HAVE_EIDRM 1
 
 /* Define to 1 if you have the <endian.h> header file. */
-/* #undef HAVE_ENDIAN_H */
+#define HAVE_ENDIAN_H 1
 
 /* Define if ENODATA exists. */
 /* #undef HAVE_ENODATA */
diff --git a/gnu/usr.bin/binutils234/block1/libctf/config.h b/gnu/usr.bin/binutils234/block1/libctf/config.h
index f0c879da25..900ec96a64 100644
--- a/gnu/usr.bin/binutils234/block1/libctf/config.h
+++ b/gnu/usr.bin/binutils234/block1/libctf/config.h
@@ -18,7 +18,7 @@
 #define HAVE_DLFCN_H 1
 
 /* Define to 1 if you have the <endian.h> header file. */
-/* #undef HAVE_ENDIAN_H */
+#define HAVE_ENDIAN_H 1
 
 /* Define to 1 if you have the `getpagesize' function. */
 #define HAVE_GETPAGESIZE 1
diff --git a/include/Makefile b/include/Makefile
index 0abb644089..5840cd4998 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -10,8 +10,9 @@ CLEANFILES= osreldate.h version vers.c vers.txt
 SUBDIR= arpa protocols rpc rpcsvc xlocale
 INCS=	a.out.h alloca.h ar.h assert.h bitstring.h cpio.h ctype.h db.h \
 	dirent.h disktab.h \
-	dlfcn.h elf.h elf-hints.h err.h float.h fmtmsg.h fnmatch.h fstab.h \
-	fts.h ftw.h getopt.h glob.h grp.h \
+	dlfcn.h elf.h elf-hints.h endian.h err.h \
+	float.h fmtmsg.h fnmatch.h fstab.h fts.h ftw.h \
+	getopt.h glob.h grp.h \
 	iconv.h ieeefp.h ifaddrs.h iso646.h inttypes.h kenv.h \
 	langinfo.h libgen.h limits.h link.h locale.h memory.h \
 	mntopts.h mpool.h mqueue.h monetary.h ndbm.h netconfig.h \
diff --git a/include/endian.h b/include/endian.h
new file mode 100644
index 0000000000..40d5f7fdc5
--- /dev/null
+++ b/include/endian.h
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (c) 2020 The DragonFly Project.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name of The DragonFly Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific, prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``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 DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ENDIAN_H_
+#define	_ENDIAN_H_
+
+#include <sys/endian.h>
+
+#endif /* !_ENDIAN_H_ */
diff --git a/lib/libssh/config.h b/lib/libssh/config.h
index ea80d48901..f337424d29 100644
--- a/lib/libssh/config.h
+++ b/lib/libssh/config.h
@@ -467,7 +467,7 @@
 #define HAVE_ENDGRENT 1
 
 /* Define to 1 if you have the <endian.h> header file. */
-/* #undef HAVE_ENDIAN_H */
+#define HAVE_ENDIAN_H 1
 
 /* Define to 1 if you have the `endutent' function. */
 /* #undef HAVE_ENDUTENT */
-- 
2.28.0

