xen/compat: support XEN_HAVE_FOO ifdefs in public interface
authorIan Campbell <ian.campbell@citrix.com>
Fri, 19 Jul 2013 11:51:07 +0000 (12:51 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 20 Aug 2013 14:40:36 +0000 (15:40 +0100)
This allows us expose or hide interface features on different architectures
without requiring nasty arch-specific ifdeffery.

Preserves any #ifdef with a XEN_HAVE_* symbol name, as well as any #else or

The ifdef symbol becomes COMPAT_HAVE in the compat versions so that
architectures can enable or disable interfaces for compat mode too. (This
actually just fell out of the way the existing stuff works and it didn't seem
worth jumping through hoops to make the name remain XEN_HAVE).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
xen/tools/compat-build-header.py
xen/tools/compat-build-source.py

index fba2f37861a7b0e418a3548ed460ba2d4a58c637..e29606295e513f3e5e9f29e380d50c276356ea7a 100755 (executable)
@@ -4,6 +4,9 @@ import re,sys
 
 pats = [
  [ r"__InClUdE__(.*)", r"#include\1\n#pragma pack(4)" ],
+ [ r"__IfDeF__ (XEN_HAVE.*)", r"#ifdef \1" ],
+ [ r"__ElSe__", r"#else" ],
+ [ r"__EnDif__", r"#endif" ],
  [ r"\"xen-compat.h\"", r"<public/xen-compat.h>" ],
  [ r"(struct|union|enum)\s+(xen_?)?(\w)", r"\1 compat_\3" ],
  [ r"@KeeP@", r"" ],
index 3906b71ea041aa550fb29cdaba62d2153f52021a..55206e637a1f8de12a697ca89cc5fa42a760c538 100755 (executable)
@@ -4,6 +4,9 @@ import re,sys
 
 pats = [
  [ r"^\s*#\s*include\s+", r"__InClUdE__ " ],
+ [ r"^\s*#\s*ifdef (XEN_HAVE.*)\s+", r"__IfDeF__ \1" ],
+ [ r"^\s*#\s*else /\* (XEN_HAVE.*) \*/\s+", r"__ElSe__" ],
+ [ r"^\s*#\s*endif /\* (XEN_HAVE.*) \*/\s+", r"__EnDif__" ],
  [ r"^\s*#\s*define\s+([A-Z_]*_GUEST_HANDLE)", r"#define HIDE_\1" ],
  [ r"^\s*#\s*define\s+([a-z_]*_guest_handle)", r"#define hide_\1" ],
  [ r"XEN_GUEST_HANDLE(_[0-9A-Fa-f]+)?", r"COMPAT_HANDLE" ],