PERFORCE change 209195 for review

John Baldwin jhb at FreeBSD.org
Sat Apr 7 12:40:22 UTC 2012


http://p4web.freebsd.org/@@209195?ac=10

Change 209195 by jhb at jhb_fiver on 2012/04/07 12:40:19

	Fix style of EVENTHANDLER_DEFINE() and add a SYSUNINIT to remove
	the tag on unload.

Affected files ...

.. //depot/projects/smpng/sys/sys/eventhandler.h#38 edit

Differences ...

==== //depot/projects/smpng/sys/sys/eventhandler.h#38 (text+ko) ====

@@ -171,15 +171,21 @@
 
 /* Operations to add and remove hooks. */
 #define EVENTHANDLER_DEFINE(name, func, arg, priority)			\
-	static eventhandler_tag name ## _tag;				\
-	static void name ## _evh_init(void *ctx)			\
-	{								\
-		name ## _tag = EVENTHANDLER_REGISTER(name, func, ctx,	\
-		    priority);						\
-	}								\
-	SYSINIT(name ## _evh_init, SI_SUB_CONFIGURE, SI_ORDER_ANY,	\
-	    name ## _evh_init, arg);					\
-	struct __hack
+static eventhandler_tag name ## _tag;					\
+									\
+static void name ## _evh_init(void *ctx)				\
+{									\
+	name ## _tag = EVENTHANDLER_REGISTER(name, func, ctx, priority); \
+}									\
+SYSINIT(name ## _evh_init, SI_SUB_CONFIGURE, SI_ORDER_ANY,		\
+    name ## _evh_init, arg);						\
+									\
+static void name ## _evh_fini(void *ctx __unused)			\
+{									\
+	EVENTHANDLER_DEREGISTER(name, name ## _tag);			\
+}									\
+SYSUNINIT(name ## _evh_fini, SI_SUB_CONFIGURE, SI_ORDER_ANY,		\
+    name ## _evh_fini, NULL)
 
 #define EVENTHANDLER_REGISTER(name, func, arg, priority)	\
 	eventhandler_register(NULL, #name, func, arg, priority)


More information about the p4-projects mailing list