]> xenbits.xensource.com Git - xen.git/commitdiff
xen: introduce a C99 headers check
authorStefano Stabellini <sstabellini@kernel.org>
Wed, 5 Apr 2017 00:17:51 +0000 (17:17 -0700)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Wed, 5 Apr 2017 13:56:19 +0000 (09:56 -0400)
Introduce a C99 headers check, for non-ANSI compliant headers: 9pfs.h
and pvcalls.h.

In addition to the usual -include stdint.h, also add -include string.h
to the C99 check to get the declaration of memcpy and size_t.

For the same reason, also add -include cstring to the C++ check when
necessary.

Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
CC: JBeulich@suse.com
.gitignore
xen/include/Makefile

index c056247fdfcb69373bfb54a51fd139704d57560f..74747cb7e742f5dae6e98843f3be95bf55fb7971 100644 (file)
@@ -285,8 +285,7 @@ xen/arch/*/efi/boot.c
 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/headers*.chk
 xen/include/asm
 xen/include/asm-*/asm-offsets.h
 xen/include/asm-x86/cpuid-autogen.h
index aca7f2051d848b9c71d53ed0556ea4165cd4ac48..495c4857859bcf01e78b56db6ed97ba1d78585b8 100644 (file)
@@ -90,11 +90,12 @@ compat/xlat.h: $(addprefix compat/.xlat/,$(xlat-y)) Makefile
 
 ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))
 
-all: headers.chk headers++.chk
+all: headers.chk headers99.chk headers++.chk
 
 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))
+PUBLIC_C99_HEADERS :=
+PUBLIC_ANSI_HEADERS := $(filter-out public/%ctl.h public/xsm/% public/%hvm/save.h $(PUBLIC_C99_HEADERS), $(PUBLIC_HEADERS))
 
 headers.chk: $(PUBLIC_ANSI_HEADERS) Makefile
        for i in $(filter %.h,$^); do \
@@ -104,16 +105,24 @@ headers.chk: $(PUBLIC_ANSI_HEADERS) Makefile
        done >$@.new
        mv $@.new $@
 
+headers99.chk: $(PUBLIC_C99_HEADERS) Makefile
+       rm -f $@.new
+       $(foreach i, $(filter %.h,$^),                                        \
+           $(CC) -x c -std=c99 -Wall -Werror                                 \
+           -include stdint.h $(foreach j, $($(i)-prereq), -include $(j).h)   \
+           -S -o /dev/null $(i)                                              \
+           || exit $$?; echo $(i) >> $@.new;)
+       mv $@.new $@
+
 headers++.chk: $(PUBLIC_HEADERS) Makefile
-       if $(CXX) -v >/dev/null 2>&1; then \
-           for i in $(filter %.h,$^); do \
-               echo '#include "'$$i'"' \
-               | $(CXX) -x c++ -std=gnu++98 -Wall -Werror -D__XEN_TOOLS__ \
-                 -include stdint.h -include public/xen.h -S -o /dev/null - \
-               || exit 1; \
-               echo $$i; \
-           done ; \
-       fi >$@.new
+       rm -f $@.new
+       $(CXX) -v >/dev/null 2>&1 || exit 0;                                  \
+       $(foreach i, $(filter %.h,$^),                                        \
+           echo "#include "\"$(i)\"                                          \
+           | $(CXX) -x c++ -std=gnu++98 -Wall -Werror -D__XEN_TOOLS__        \
+             -include stdint.h -include public/xen.h                         \
+             $(foreach j, $($(i)-prereq), -include c$(j)) -S -o /dev/null -  \
+           || exit $$?; echo $(i) >> $@.new;)
        mv $@.new $@
 
 endif
@@ -128,5 +137,5 @@ all: $(BASEDIR)/include/asm-x86/cpuid-autogen.h
 endif
 
 clean::
-       rm -rf compat headers.chk headers++.chk
+       rm -rf compat headers*.chk
        rm -f $(BASEDIR)/include/asm-x86/cpuid-autogen.h