aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2020-10-16 14:59:36 +0100
committerMichael Brown <mcb30@ipxe.org>2020-10-16 15:16:00 +0100
commitc504c1d6937a07b038ad21646eaec51f34684736 (patch)
tree7540c7f46666454ed66c7ad48480648623d10610 /src
parent49fd66a8c9d94b7d66656ea5d844278109ee2eef (diff)
downloadipxe-c504c1d6937a07b038ad21646eaec51f34684736.tar.gz
[interface] Allow for the definition of an unused interface operation
Allow an interface operation to be declared as unused. This will perform full type-checking and compilation of the implementing method, without including any code in the resulting object (other than a NULL entry in the interface operations table). The intention is to provide a relatively clean way for interface operation methods to be omitted in builds for which the operation is not required (such as an operation to describe an object using an EFI device path, which would not be required in a non-EFI build). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r--src/include/ipxe/interface.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/include/ipxe/interface.h b/src/include/ipxe/interface.h
index b65002c80..9281aeef5 100644
--- a/src/include/ipxe/interface.h
+++ b/src/include/ipxe/interface.h
@@ -36,6 +36,21 @@ struct interface_operation {
? op_func : op_func ), \
}
+/**
+ * Define an unused object interface operation
+ *
+ * @v op_type Operation type
+ * @v object_type Implementing method's expected object type
+ * @v op_func Implementing method
+ * @ret op Object interface operation
+ */
+#define UNUSED_INTF_OP( op_type, object_type, op_func ) { \
+ .type = NULL, \
+ .func = ( ( ( ( typeof ( op_func ) * ) NULL ) == \
+ ( ( op_type ## _TYPE ( object_type ) * ) NULL ) ) \
+ ? NULL : NULL ), \
+ }
+
/** An object interface descriptor */
struct interface_descriptor {
/** Offset of interface within containing object */