[PATCH] Add FreeBSD kernel space header files

2018-08-09 Thread Sebastian Huber
Move the kernel space content of some Newlib provided header files to
RTEMS and libbsd.  This allows to use the Newlib provided header files
with different FreeBSD baselines.

Update #3472.
---
 cpukit/headers.am |   3 +
 cpukit/include/machine/_kernel_in.h   |  60 +
 cpukit/include/machine/_kernel_in6.h  | 181 ++
 cpukit/include/machine/_kernel_uio.h  |  87 +
 cpukit/libnetworking/headers.am   |   2 +
 cpukit/libnetworking/machine/_kernel_if.h |  44 +++
 cpukit/libnetworking/machine/_kernel_socket.h |  83 
 7 files changed, 460 insertions(+)
 create mode 100644 cpukit/include/machine/_kernel_in.h
 create mode 100644 cpukit/include/machine/_kernel_in6.h
 create mode 100644 cpukit/include/machine/_kernel_uio.h
 create mode 100644 cpukit/libnetworking/machine/_kernel_if.h
 create mode 100644 cpukit/libnetworking/machine/_kernel_socket.h

diff --git a/cpukit/headers.am b/cpukit/headers.am
index fb6e1fc009..9c13fefe02 100644
--- a/cpukit/headers.am
+++ b/cpukit/headers.am
@@ -67,9 +67,12 @@ include_linux_spi_HEADERS += include/linux/spi/spidev.h
 include_machinedir = $(includedir)/machine
 include_machine_HEADERS =
 include_machine_HEADERS += include/machine/_kernel_cpuset.h
+include_machine_HEADERS += include/machine/_kernel_in.h
+include_machine_HEADERS += include/machine/_kernel_in6.h
 include_machine_HEADERS += include/machine/_kernel_param.h
 include_machine_HEADERS += include/machine/_kernel_time.h
 include_machine_HEADERS += include/machine/_kernel_types.h
+include_machine_HEADERS += include/machine/_kernel_uio.h
 include_machine_HEADERS += include/machine/_timecounter.h
 
 include_mghttpddir = $(includedir)/mghttpd
diff --git a/cpukit/include/machine/_kernel_in.h 
b/cpukit/include/machine/_kernel_in.h
new file mode 100644
index 00..0dad7f534e
--- /dev/null
+++ b/cpukit/include/machine/_kernel_in.h
@@ -0,0 +1,60 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * 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
+ * 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 University 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 REGENTS 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 REGENTS 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.
+ *
+ * @(#)in.h8.3 (Berkeley) 1/3/94
+ * $FreeBSD: head/sys/netinet/in.h 326023 2017-11-20 19:43:44Z pfg $
+ */
+
+#if !defined(_NETINET_IN_H_) || !defined(_KERNEL)
+#error "must be included via  in kernel space"
+#endif
+
+struct ifnet; struct mbuf; /* forward declarations for Standard C */
+struct in_ifaddr;
+
+int in_broadcast(struct in_addr, struct ifnet *);
+int in_ifaddr_broadcast(struct in_addr, struct in_ifaddr *);
+int in_canforward(struct in_addr);
+int in_localaddr(struct in_addr);
+int in_localip(struct in_addr);
+int in_ifhasaddr(struct ifnet *, struct in_addr);
+int inet_aton(const char *, struct in_addr *); /* in libkern */
+char   *inet_ntoa_r(struct in_addr ina, char *buf); /* in libkern */
+char   *inet_ntop(int, const void *, char *, socklen_t); /* in libkern */
+int inet_pton(int af, const char *, void *); /* in libkern */
+voidin_ifdetach(struct ifnet *);
+
+#definein_hosteq(s, t) ((s).s_addr == (t).s_addr)
+#definein_nullhost(x)  ((x).s_addr == INADDR_ANY)
+#definein_allhosts(x)  ((x).s_addr == htonl(INADDR_ALLHOSTS_GROUP))
+
+#definesatosin(sa) ((struct sockaddr_in *)(sa))
+#definesintosa(sin)((struct sockaddr *)(sin))
+#defineifatoia(ifa)((struct in_ifaddr *)(ifa))
diff --git 

[PATCH] Add FreeBSD kernel space header files

2018-08-09 Thread Sebastian Huber
Move the kernel space content of some Newlib provided header files to
RTEMS and libbsd.  This allows to use the Newlib provided header files
with different FreeBSD baselines.

Update #3472.
---
 rtemsbsd/include/machine/_kernel_if.h | 44 
 rtemsbsd/include/machine/_kernel_socket.h | 83 +++
 2 files changed, 127 insertions(+)
 create mode 100644 rtemsbsd/include/machine/_kernel_if.h
 create mode 100644 rtemsbsd/include/machine/_kernel_socket.h

diff --git a/rtemsbsd/include/machine/_kernel_if.h 
b/rtemsbsd/include/machine/_kernel_if.h
new file mode 100644
index 0..b360a41b2
--- /dev/null
+++ b/rtemsbsd/include/machine/_kernel_if.h
@@ -0,0 +1,44 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * 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
+ * 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 University 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 REGENTS 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 REGENTS 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.
+ *
+ * @(#)if.h8.1 (Berkeley) 6/10/93
+ * $FreeBSD: head/sys/net/if.h 333502 2018-05-11 20:08:28Z mmacy $
+ */
+
+#if !defined(_NET_IF_H_) || !defined(_KERNEL)
+#error "must be included via  in kernel space"
+#endif
+
+#ifdef MALLOC_DECLARE
+MALLOC_DECLARE(M_IFADDR);
+MALLOC_DECLARE(M_IFMADDR);
+#endif
+
+#defineifr_dataifr_ifru.ifru_data  /* for use by interface 
*/
diff --git a/rtemsbsd/include/machine/_kernel_socket.h 
b/rtemsbsd/include/machine/_kernel_socket.h
new file mode 100644
index 0..e9acc744f
--- /dev/null
+++ b/rtemsbsd/include/machine/_kernel_socket.h
@@ -0,0 +1,83 @@
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
+ * 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
+ * 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 University 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 REGENTS 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 REGENTS 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.
+ *
+ * @(#)socket.h8.4 (Berkeley) 2/21/94
+ * $FreeBSD: head/sys/sys/socket.h 334719 2018-06-06 15:45:57Z sbruno $
+ */
+
+#if !defined(_SYS_SOCKET_H_) || !defined(_KERNEL)
+#error "must be included via  in kernel space"
+#endif
+
+/*
+ * Flags for accept1(), kern_accept4()