@@ -826,25 +826,31 @@ Configuring the schema
826826Syntax::
827827
828828 COND = STRING
829- | [ STRING, ... ]
829+ | { 'all: [ COND, ... ] }
830+ | { 'any: [ COND, ... ] }
831+ | { 'not': COND }
830832
831833All definitions take an optional 'if' member. Its value must be a
832- string or a list of strings. A string is shorthand for a list
833- containing just that string. The code generated for the definition
834- will then be guarded by #if STRING for each STRING in the COND list.
834+ string, or an object with a single member 'all', 'any' or 'not'.
835+
836+ The C code generated for the definition will then be guarded by an #if
837+ preprocessing directive with an operand generated from that condition:
838+
839+ * STRING will generate defined(STRING)
840+ * { 'all': [COND, ...] } will generate (COND && ...)
841+ * { 'any': [COND, ...] } will generate (COND || ...)
842+ * { 'not': COND } will generate !COND
835843
836844Example: a conditional struct ::
837845
838846 { 'struct': 'IfStruct', 'data': { 'foo': 'int' },
839- 'if': ['defined( CONFIG_FOO) ', 'defined( HAVE_BAR)'] }
847+ 'if': { 'all': [ ' CONFIG_FOO', 'HAVE_BAR' ] } }
840848
841849gets its generated code guarded like this::
842850
843- #if defined(CONFIG_FOO)
844- #if defined(HAVE_BAR)
851+ #if defined(CONFIG_FOO) && defined(HAVE_BAR)
845852 ... generated code ...
846- #endif /* defined(HAVE_BAR) */
847- #endif /* defined(CONFIG_FOO) */
853+ #endif /* defined(HAVE_BAR) && defined(CONFIG_FOO) */
848854
849855Individual members of complex types, commands arguments, and
850856event-specific data can also be made conditional. This requires the
@@ -855,7 +861,7 @@ member 'bar' ::
855861
856862 { 'struct': 'IfStruct', 'data':
857863 { 'foo': 'int',
858- 'bar': { 'type': 'int', 'if': 'defined( IFCOND) '} } }
864+ 'bar': { 'type': 'int', 'if': 'IFCOND'} } }
859865
860866A union's discriminator may not be conditional.
861867
@@ -867,7 +873,7 @@ value 'bar' ::
867873
868874 { 'enum': 'IfEnum', 'data':
869875 [ 'foo',
870- { 'name' : 'bar', 'if': 'defined( IFCOND) ' } ] }
876+ { 'name' : 'bar', 'if': 'IFCOND' } ] }
871877
872878Likewise, features can be conditional. This requires the longhand
873879form of FEATURE _.
@@ -877,7 +883,7 @@ Example: a struct with conditional feature 'allow-negative-numbers' ::
877883 { 'struct': 'TestType',
878884 'data': { 'number': 'int' },
879885 'features': [ { 'name': 'allow-negative-numbers',
880- 'if': 'defined( IFCOND) ' } ] }
886+ 'if': 'IFCOND' } ] }
881887
882888Please note that you are responsible to ensure that the C code will
883889compile with an arbitrary combination of conditions, since the
0 commit comments