]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[interface] Add intf_poke() helper
authorMichael Brown <mcb30@ipxe.org>
Wed, 8 Jul 2015 15:24:11 +0000 (16:24 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 22 Jul 2015 20:17:47 +0000 (21:17 +0100)
Reduce the cost of implementing object methods which convey no
information beyond the fact that the method has been called.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/interface.c
src/include/ipxe/interface.h

index 400fac14f28102d4b234b41dda74d49136b91282..ba148c13dfd9eeec50ce16727bb24bc41659bfe5 100644 (file)
@@ -311,3 +311,28 @@ void intf_restart ( struct interface *intf, int rc ) {
         */
        intf->desc = desc;
 }
+
+/**
+ * Poke an object interface
+ *
+ * @v intf             Object interface
+ * @v type             Operation type
+ *
+ * This is a helper function to implement methods which take no
+ * parameters and return nothing.
+ */
+void intf_poke ( struct interface *intf,
+                void ( type ) ( struct interface *intf ) ) {
+       struct interface *dest;
+       intf_poke_TYPE ( void * ) *op =
+               intf_get_dest_op_untyped ( intf, type, &dest );
+       void *object = intf_object ( dest );
+
+       if ( op ) {
+               op ( object );
+       } else {
+               /* Default is to do nothing */
+       }
+
+       intf_put ( dest );
+}
index efb8374648da790074d63fc9935081b1f54bc7c5..a8d8237753827168b74827e9b79659f43f82e41a 100644 (file)
@@ -145,6 +145,11 @@ extern void intf_close ( struct interface *intf, int rc );
 extern void intf_shutdown ( struct interface *intf, int rc );
 extern void intf_restart ( struct interface *intf, int rc );
 
+extern void intf_poke ( struct interface *intf,
+                       void ( type ) ( struct interface *intf ) );
+#define intf_poke_TYPE( object_type ) \
+       typeof ( void ( object_type ) )
+
 extern struct interface_descriptor null_intf_desc;
 extern struct interface null_intf;