[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v5 2/4] xen: introduce a C99 headers check



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@xxxxxxxxxxx>
CC: JBeulich@xxxxxxxx
CC: konrad.wilk@xxxxxxxxxx
---
 .gitignore           |  1 +
 xen/include/Makefile | 29 +++++++++++++++++++++++++----
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 443b12a..a8905b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -274,6 +274,7 @@ xen/arch/*/efi/compat.c
 xen/arch/*/efi/efi.h
 xen/arch/*/efi/runtime.c
 xen/include/headers.chk
+xen/include/headers99.chk
 xen/include/headers++.chk
 xen/include/asm
 xen/include/asm-*/asm-offsets.h
diff --git a/xen/include/Makefile b/xen/include/Makefile
index aca7f20..f9d18cd 100644
--- a/xen/include/Makefile
+++ b/xen/include/Makefile
@@ -90,11 +90,16 @@ 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))
+
+EXTRA_PREREQ_C99 := -include string.h
+EXTRA_PREREQ_CPP := -include cstring
+HEADERS_HAVE_EXTRA_PREREQ := $(PUBLIC_C99_HEADERS)
 
 headers.chk: $(PUBLIC_ANSI_HEADERS) Makefile
        for i in $(filter %.h,$^); do \
@@ -104,12 +109,28 @@ headers.chk: $(PUBLIC_ANSI_HEADERS) Makefile
        done >$@.new
        mv $@.new $@
 
+headers99.chk: $(PUBLIC_C99_HEADERS) Makefile
+       for i in $(filter %.h,$^); do \
+           $(CC) -x c -std=c99 -Wall -Werror -include stdint.h \
+                 $(EXTRA_PREREQ_C99) -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 \
+               for j in $(HEADERS_HAVE_EXTRA_PREREQ); do \
+                   extra="" ; \
+                   if test "$$j" = "$$i"; then \
+                       extra="$(EXTRA_PREREQ_CPP)" ; \
+                       break ; \
+                   fi ; \
+               done ; \
                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 - \
+                 -include stdint.h $$extra -include public/xen.h \
+                 -S -o /dev/null - \
                || exit 1; \
                echo $$i; \
            done ; \
@@ -128,5 +149,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
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.