Blob Blame History Raw
########################################
#
# Macros for switching between source policy
# and loadable policy module support
#

##############################
#
# For adding the module statement
#
define(`policy_module',`
	ifdef(`monolithic_policy',`',`
		module $1 $2;
	')
')

##############################
#
# For use in interfaces, to optionally insert a requires block
#
define(`requires_block_template',`
	ifdef(`monolithic_policy',`',`
		require {
			$1
		}
	')
')

##############################
#
# Optional policy handling
#
define(`optional_policy',`
	ifdef(`monolithic_policy',`
		ifdef(`$1',$2,$3)
	',`
		optional {
			$2
		} else {
			$3
		}
	')
')

##############################
#
# Determine if we should use the default
# tunable value as specified by the policy
# or if the override value should be used
#
define(`deflt_or_overr',`ifdef(`$1',$1,$2)')

##############################
#
# Tunable declaration
#
define(`tunable_def',`
	ifdef(`monolithic_policy',`
		bool $1 deflt_or_overr(`$1'_conf,$2);
	',`
		# loadable module tunable
		# declaration will go here
		# for $1 $2
	')
')

##############################
#
# Tunable policy handling
#
define(`tunable_policy',`
	ifdef(`monolithic_policy',`
		if (`$1') {
			$2
		} else {
			$3
		}
	',`
		optional {
			require { `$1' }
			$2
		} else {
			$3
		}
	')
')