PERFORCE change 94932 for review

John Baldwin jhb at FreeBSD.org
Mon Apr 10 18:40:02 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=94932

Change 94932 by jhb at jhb_slimer on 2006/04/10 18:39:34

	Use the kernel linker to lookup our linker set instead of depending
	on ld(8).

Affected files ...

.. //depot/projects/smpng/sys/modules/crash/crash.c#30 edit

Differences ...

==== //depot/projects/smpng/sys/modules/crash/crash.c#30 (text+ko) ====

@@ -44,6 +44,7 @@
 #include <sys/kdb.h>
 #include <sys/kernel.h>
 #include <sys/kthread.h>
+#include <sys/linker.h>
 #include <sys/lock.h>
 #include <sys/module.h>
 #include <sys/mutex.h>
@@ -61,15 +62,15 @@
 	void (*ev_handler)(void);
 };
 
-SET_DECLARE(crash_event_set, struct crash_event);
-
 #define	CRASH_EVENT(name, function)					\
 	static struct crash_event function ## _crash_event =		\
 	    { name, function };						\
 	DATA_SET(crash_event_set, function ## _crash_event)
 
-#define	MAX_EVENT	SET_COUNT(crash_event_set)
+#define	MAX_EVENT	event_max
 
+static int event_max;
+static struct crash_event **event_start, **event_stop;
 static struct rwlock baz;
 static struct sx foo, bar, bar2;
 static struct cv event_cv;
@@ -630,12 +631,11 @@
 {
 	struct crash_event **ev;
 
-	SET_FOREACH(ev, crash_event_set) {
+	for (ev = event_start; ev < event_stop; ev++) {
 		/* Skip null event 0. */
 		if ((*ev)->ev_name == NULL)
 			continue;
-		printf("%4td  %s\n", ev - SET_BEGIN(crash_event_set),
-		    (*ev)->ev_name);
+		printf("%4td  %s\n", ev - event_start, (*ev)->ev_name);
 	}
 }
 CRASH_EVENT("help", help);
@@ -692,7 +692,7 @@
 			printf("crash: event %d is not defined!\n", event);
 			continue;
 		}
-		evp = SET_ITEM(crash_event_set, ev);
+		evp = event_start[ev];
 		printf("crash: %s\n", evp->ev_name);
 		evp->ev_handler();
 	}
@@ -758,6 +758,10 @@
 
 	switch (cmd) {
 	case MOD_LOAD:
+		error = linker_file_lookup_set(module_file(module),
+		    "crash_event_set", &event_start, &event_stop, &event_max);
+		if (error)
+			break;
 		error = load(arg);
 		break;
 	case MOD_UNLOAD:


More information about the p4-projects mailing list