[rtems-libbsd commit] Add file to ensure some C++ compatibility
Sebastian Huber
sebh at rtems.org
Wed Sep 17 09:51:53 UTC 2014
Module: rtems-libbsd
Branch: master
Commit: 7e982cf603da8fe3a1cd290d28bb00c7f60d1be0
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=7e982cf603da8fe3a1cd290d28bb00c7f60d1be0
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Fri Aug 29 11:01:39 2014 +0200
Add file to ensure some C++ compatibility
---
Makefile | 56 ++++++++++++++++++----------------
freebsd-to-rtems.py | 58 +++++++++++++++++++----------------
rtemsbsd/rtems/rtems-bsd-cxx.cc | 64 +++++++++++++++++++++++++++++++++++++++
3 files changed, 125 insertions(+), 53 deletions(-)
diff --git a/Makefile b/Makefile
index bc959dd..a5d4c67 100644
--- a/Makefile
+++ b/Makefile
@@ -5,31 +5,33 @@ include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/leaf.cfg
-CFLAGS += -ffreestanding
-CFLAGS += -fno-common
-CFLAGS += -Irtemsbsd/include
-CFLAGS += -Irtemsbsd/$(RTEMS_CPU)/include
-CFLAGS += -Ifreebsd/sys
-CFLAGS += -Ifreebsd/sys/$(RTEMS_CPU)/include
-CFLAGS += -Ifreebsd/sys/contrib/altq
-CFLAGS += -Ifreebsd/sys/contrib/pf
-CFLAGS += -Icopied/rtemsbsd/$(RTEMS_CPU)/include
-CFLAGS += -Ifreebsd/include
-CFLAGS += -Ifreebsd/lib/libc/include
-CFLAGS += -Ifreebsd/lib/libc/isc/include
-CFLAGS += -Ifreebsd/lib/libc/resolv
-CFLAGS += -Ifreebsd/lib/libutil
-CFLAGS += -Ifreebsd/lib/libkvm
-CFLAGS += -Ifreebsd/lib/libmemstat
-CFLAGS += -Ifreebsd/lib/libipsec
-CFLAGS += -ImDNSResponder/mDNSCore
-CFLAGS += -ImDNSResponder/mDNSShared
-CFLAGS += -ImDNSResponder/mDNSPosix
-CFLAGS += -Itestsuite/include
-CFLAGS += -Wall
-CFLAGS += -Wno-format
+COMMON_FLAGS += -ffreestanding
+COMMON_FLAGS += -fno-common
+COMMON_FLAGS += -Irtemsbsd/include
+COMMON_FLAGS += -Irtemsbsd/$(RTEMS_CPU)/include
+COMMON_FLAGS += -Ifreebsd/sys
+COMMON_FLAGS += -Ifreebsd/sys/$(RTEMS_CPU)/include
+COMMON_FLAGS += -Ifreebsd/sys/contrib/altq
+COMMON_FLAGS += -Ifreebsd/sys/contrib/pf
+COMMON_FLAGS += -Icopied/rtemsbsd/$(RTEMS_CPU)/include
+COMMON_FLAGS += -Ifreebsd/include
+COMMON_FLAGS += -Ifreebsd/lib/libc/include
+COMMON_FLAGS += -Ifreebsd/lib/libc/isc/include
+COMMON_FLAGS += -Ifreebsd/lib/libc/resolv
+COMMON_FLAGS += -Ifreebsd/lib/libutil
+COMMON_FLAGS += -Ifreebsd/lib/libkvm
+COMMON_FLAGS += -Ifreebsd/lib/libmemstat
+COMMON_FLAGS += -Ifreebsd/lib/libipsec
+COMMON_FLAGS += -ImDNSResponder/mDNSCore
+COMMON_FLAGS += -ImDNSResponder/mDNSShared
+COMMON_FLAGS += -ImDNSResponder/mDNSPosix
+COMMON_FLAGS += -Itestsuite/include
+COMMON_FLAGS += -Wall
+COMMON_FLAGS += -Wno-format
+COMMON_FLAGS += -MT $@ -MD -MP -MF $(basename $@).d
+CFLAGS += $(COMMON_FLAGS)
CFLAGS += -std=gnu99
-CFLAGS += -MT $@ -MD -MP -MF $(basename $@).d
+CXXFLAGS += $(COMMON_FLAGS)
NEED_DUMMY_PIC_IRQ=yes
TEST_NETWORK_CONFIG = testsuite/include/rtems/bsd/test/network-config.h
@@ -46,6 +48,8 @@ D_FILES =
LIB = libbsd.a
LIB_GEN_FILES =
LIB_C_FILES =
+LIB_CXX_FILES =
+LIB_CXX_FILES += rtemsbsd/rtems/rtems-bsd-cxx.cc
LIB_C_FILES += rtemsbsd/local/bus_if.c
LIB_C_FILES += rtemsbsd/local/cryptodev_if.c
LIB_C_FILES += rtemsbsd/local/device_if.c
@@ -1431,9 +1435,9 @@ LIB_C_FILES += mDNSResponder/mDNSPosix/mDNSUNP.c
ifeq ($(NEED_DUMMY_PIC_IRQ),yes)
CFLAGS += -I rtems-dummy-pic-irq/include
endif
-LIB_O_FILES = $(LIB_C_FILES:%.c=%.o)
+LIB_O_FILES = $(LIB_C_FILES:%.c=%.o) $(LIB_CXX_FILES:%.cc=%.o)
O_FILES += $(LIB_O_FILES)
-D_FILES += $(LIB_C_FILES:%.c=%.d)
+D_FILES += $(LIB_C_FILES:%.c=%.d) $(LIB_CXX_FILES:%.cc=%.d)
all: $(LIB) $(TESTS) $(TEST_NETWORK_CONFIG) $(NET_TESTS)
diff --git a/freebsd-to-rtems.py b/freebsd-to-rtems.py
index 6bbb361..3d21a38 100755
--- a/freebsd-to-rtems.py
+++ b/freebsd-to-rtems.py
@@ -411,31 +411,33 @@ class ModuleManager:
'include $(RTEMS_CUSTOM)\n' \
'include $(PROJECT_ROOT)/make/leaf.cfg\n' \
'\n' \
- 'CFLAGS += -ffreestanding\n' \
- 'CFLAGS += -fno-common\n' \
- 'CFLAGS += -Irtemsbsd/include\n' \
- 'CFLAGS += -Irtemsbsd/$(RTEMS_CPU)/include\n' \
- 'CFLAGS += -Ifreebsd/sys\n' \
- 'CFLAGS += -Ifreebsd/sys/$(RTEMS_CPU)/include\n' \
- 'CFLAGS += -Ifreebsd/sys/contrib/altq\n' \
- 'CFLAGS += -Ifreebsd/sys/contrib/pf\n' \
- 'CFLAGS += -Icopied/rtemsbsd/$(RTEMS_CPU)/include\n' \
- 'CFLAGS += -Ifreebsd/include\n' \
- 'CFLAGS += -Ifreebsd/lib/libc/include\n' \
- 'CFLAGS += -Ifreebsd/lib/libc/isc/include\n' \
- 'CFLAGS += -Ifreebsd/lib/libc/resolv\n' \
- 'CFLAGS += -Ifreebsd/lib/libutil\n' \
- 'CFLAGS += -Ifreebsd/lib/libkvm\n' \
- 'CFLAGS += -Ifreebsd/lib/libmemstat\n' \
- 'CFLAGS += -Ifreebsd/lib/libipsec\n' \
- 'CFLAGS += -ImDNSResponder/mDNSCore\n' \
- 'CFLAGS += -ImDNSResponder/mDNSShared\n' \
- 'CFLAGS += -ImDNSResponder/mDNSPosix\n' \
- 'CFLAGS += -Itestsuite/include\n' \
- 'CFLAGS += -Wall\n' \
- 'CFLAGS += -Wno-format\n' \
+ 'COMMON_FLAGS += -ffreestanding\n' \
+ 'COMMON_FLAGS += -fno-common\n' \
+ 'COMMON_FLAGS += -Irtemsbsd/include\n' \
+ 'COMMON_FLAGS += -Irtemsbsd/$(RTEMS_CPU)/include\n' \
+ 'COMMON_FLAGS += -Ifreebsd/sys\n' \
+ 'COMMON_FLAGS += -Ifreebsd/sys/$(RTEMS_CPU)/include\n' \
+ 'COMMON_FLAGS += -Ifreebsd/sys/contrib/altq\n' \
+ 'COMMON_FLAGS += -Ifreebsd/sys/contrib/pf\n' \
+ 'COMMON_FLAGS += -Icopied/rtemsbsd/$(RTEMS_CPU)/include\n' \
+ 'COMMON_FLAGS += -Ifreebsd/include\n' \
+ 'COMMON_FLAGS += -Ifreebsd/lib/libc/include\n' \
+ 'COMMON_FLAGS += -Ifreebsd/lib/libc/isc/include\n' \
+ 'COMMON_FLAGS += -Ifreebsd/lib/libc/resolv\n' \
+ 'COMMON_FLAGS += -Ifreebsd/lib/libutil\n' \
+ 'COMMON_FLAGS += -Ifreebsd/lib/libkvm\n' \
+ 'COMMON_FLAGS += -Ifreebsd/lib/libmemstat\n' \
+ 'COMMON_FLAGS += -Ifreebsd/lib/libipsec\n' \
+ 'COMMON_FLAGS += -ImDNSResponder/mDNSCore\n' \
+ 'COMMON_FLAGS += -ImDNSResponder/mDNSShared\n' \
+ 'COMMON_FLAGS += -ImDNSResponder/mDNSPosix\n' \
+ 'COMMON_FLAGS += -Itestsuite/include\n' \
+ 'COMMON_FLAGS += -Wall\n' \
+ 'COMMON_FLAGS += -Wno-format\n' \
+ 'COMMON_FLAGS += -MT $@ -MD -MP -MF $(basename $@).d\n' \
+ 'CFLAGS += $(COMMON_FLAGS)\n' \
'CFLAGS += -std=gnu99\n' \
- 'CFLAGS += -MT $@ -MD -MP -MF $(basename $@).d\n' \
+ 'CXXFLAGS += $(COMMON_FLAGS)\n' \
'NEED_DUMMY_PIC_IRQ=yes\n' \
'\n' \
'TEST_NETWORK_CONFIG = testsuite/include/rtems/bsd/test/network-config.h\n' \
@@ -451,7 +453,9 @@ class ModuleManager:
'\n' \
'LIB = libbsd.a\n' \
'LIB_GEN_FILES =\n' \
- 'LIB_C_FILES =\n'
+ 'LIB_C_FILES =\n' \
+ 'LIB_CXX_FILES =\n' \
+ 'LIB_CXX_FILES += rtemsbsd/rtems/rtems-bsd-cxx.cc\n'
for m in self.modules:
if m.conditionalOn != "none":
data += 'ifneq ($(' + m.conditionalOn + '),yes)\n'
@@ -471,9 +475,9 @@ class ModuleManager:
'ifeq ($(NEED_DUMMY_PIC_IRQ),yes)\n' \
'CFLAGS += -I rtems-dummy-pic-irq/include\n' \
'endif\n' \
- 'LIB_O_FILES = $(LIB_C_FILES:%.c=%.o)\n' \
+ 'LIB_O_FILES = $(LIB_C_FILES:%.c=%.o) $(LIB_CXX_FILES:%.cc=%.o)\n' \
'O_FILES += $(LIB_O_FILES)\n' \
- 'D_FILES += $(LIB_C_FILES:%.c=%.d)\n' \
+ 'D_FILES += $(LIB_C_FILES:%.c=%.d) $(LIB_CXX_FILES:%.cc=%.d)\n' \
'\n' \
'all: $(LIB) $(TESTS) $(TEST_NETWORK_CONFIG) $(NET_TESTS)\n' \
'\n' \
diff --git a/rtemsbsd/rtems/rtems-bsd-cxx.cc b/rtemsbsd/rtems/rtems-bsd-cxx.cc
new file mode 100644
index 0000000..db97b84
--- /dev/null
+++ b/rtemsbsd/rtems/rtems-bsd-cxx.cc
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems at embedded-brains.de>
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+#define __STDC_LIMIT_MACROS
+#define __STDC_CONSTANT_MACROS
+
+extern "C" {
+
+#include <machine/rtems-bsd-kernel-space.h>
+
+#include <rtems/bsd/sys/param.h>
+#include <rtems/bsd/sys/types.h>
+#include <sys/mbuf.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+
+#include <sys/bus.h>
+#include <machine/bus.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
+#include <net/if_types.h>
+#include <net/if_var.h>
+
+}
+
+/*
+ * Just make sure that these header files are C++ compatible to enable network
+ * interface drivers in C++.
+ */
More information about the vc
mailing list