]> xenbits.xensource.com Git - xen.git/commitdiff
Automatically check xen's public headers for C++ pitfalls.
authorTim Deegan <tim@xen.org>
Fri, 27 Feb 2015 09:46:34 +0000 (09:46 +0000)
committerTim Deegan <tim@xen.org>
Fri, 27 Feb 2015 09:46:34 +0000 (09:46 +0000)
Add a check, like the existing check for non-ANSI C in the public
headers, that runs the public headers through a C++ compiler to
flag non-C++-friendly constructs.

Unlike the ANSI C check, we accept GCC-isms (gnu++98), and we also
check various tools-only headers.

Also tidy up the runes for these checks to be a bit more readable.

io/ring.h uses 'private' as a field name, which is a keyword in C++;
this patch doesn't change that.  Instead the check works around it.

Reported-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <JBeulich@suse.com>
Tested-by: Don Slutz <dslutz@verizon.com>
.gitignore
config/StdGNU.mk
config/SunOS.mk
xen/include/Makefile
xen/include/public/xsm/flask_op.h

index 13ee05b919c9d8c48dc5cc7db57036eec9d1561c..78958ea505218e9666e7a1fabe32ff1ff22b0400 100644 (file)
@@ -233,6 +233,7 @@ xen/arch/*/efi/compat.c
 xen/arch/*/efi/efi.h
 xen/arch/*/efi/runtime.c
 xen/include/headers.chk
+xen/include/headers++.chk
 xen/include/asm
 xen/include/asm-*/asm-offsets.h
 xen/include/compat/*
index 4efebe391076d117f9cbb10863a0d72fbc5467f5..e10ed39ec78c85f5087fba80e27a6a4c214c393a 100644 (file)
@@ -2,9 +2,11 @@ AS         = $(CROSS_COMPILE)as
 LD         = $(CROSS_COMPILE)ld
 ifeq ($(clang),y)
 CC         = $(CROSS_COMPILE)clang
+CXX        = $(CROSS_COMPILE)clang++
 LD_LTO     = $(CROSS_COMPILE)llvm-ld
 else
 CC         = $(CROSS_COMPILE)gcc
+CXX        = $(CROSS_COMPILE)g++
 LD_LTO     = $(CROSS_COMPILE)ld
 endif
 CPP        = $(CC) -E
index 331628052e3a6cb9d3dc1ecc5f51e9011ca6a299..c2be37d6302e672551931e0707d87db61b02f245 100644 (file)
@@ -2,6 +2,7 @@ AS         = $(CROSS_COMPILE)gas
 LD         = $(CROSS_COMPILE)gld
 CC         = $(CROSS_COMPILE)gcc
 CPP        = $(CROSS_COMPILE)gcc -E
+CXX        = $(CROSS_COMPILE)g++
 AR         = $(CROSS_COMPILE)gar
 RANLIB     = $(CROSS_COMPILE)granlib
 NM         = $(CROSS_COMPILE)gnm
index 94112d16222a4de63dc9bd010bff434533e2793a..d48a642b56ed573422af59fcdd3d0ae0ab0114ea 100644 (file)
@@ -87,13 +87,33 @@ compat/xlat.h: $(addprefix compat/.xlat/,$(xlat-y)) Makefile
 
 ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))
 
-all: headers.chk
+all: headers.chk headers++.chk
 
-headers.chk: $(filter-out public/arch-% public/%ctl.h public/xsm/% public/%hvm/save.h, $(wildcard public/*.h public/*/*.h) $(public-y)) Makefile
-       for i in $(filter %.h,$^); do $(CC) -ansi -include stdint.h -Wall -W -Werror -S -o /dev/null -x c $$i || exit 1; echo $$i; done >$@.new
+PUBLIC_HEADERS := $(filter-out public/arch-% public/dom0_ops.h, $(wildcard public/*.h public/*/*.h) $(public-y))
+
+PUBLIC_ANSI_HEADERS := $(filter-out public/%ctl.h public/xsm/% public/%hvm/save.h, $(PUBLIC_HEADERS))
+
+headers.chk: $(PUBLIC_ANSI_HEADERS) Makefile
+       for i in $(filter %.h,$^); do \
+           $(CC) -x c -ansi -Wall -Werror -include stdint.h \
+                 -S -o /dev/null $$i || exit 1; \
+           echo $$i; \
+       done >$@.new
+       mv $@.new $@
+
+headers++.chk: $(PUBLIC_HEADERS) Makefile
+       if $(CXX) -v >/dev/null 2>&1; then \
+           for i in $(filter %.h,$^); do \
+               $(CXX) -x c++ -std=gnu++98 -Wall -Werror \
+                      -D__XEN_TOOLS__ -Dprivate=private_is_a_keyword_in_cpp \
+                      -include stdint.h -include public/xen.h \
+                      -S -o /dev/null $$i || exit 1; \
+               echo $$i; \
+           done ; \
+       fi >$@.new
        mv $@.new $@
 
 endif
 
 clean::
-       rm -rf compat headers.chk
+       rm -rf compat headers.chk headers++.chk
index 233de8120b0b83f43c1ffea11e2b229dd3d49c26..f874589fc83c3067809b3fa1d0b0fd27630fe4a9 100644 (file)
@@ -25,6 +25,8 @@
 #ifndef __FLASK_OP_H__
 #define __FLASK_OP_H__
 
+#include "../event_channel.h"
+
 #define XEN_FLASK_INTERFACE_VERSION 1
 
 struct xen_flask_load {