PERFORCE change 94276 for review

John Baldwin jhb at FreeBSD.org
Wed Mar 29 23:10:18 UTC 2006


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

Change 94276 by jhb at jhb_slimer on 2006/03/29 23:10:05

	If USE_SET is not defined (turned off for amd64 for now), then ask
	the linker to lookup our set of events for us instead of assuming
	that ld(1) will do all the heavy-lifting for us.  Evil I am.

Affected files ...

.. //depot/projects/smpng/sys/modules/crash2/crash2.c#5 edit

Differences ...

==== //depot/projects/smpng/sys/modules/crash2/crash2.c#5 (text+ko) ====

@@ -47,6 +47,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>
@@ -60,6 +61,10 @@
 
 #define	NTHREADS	4
 
+#ifndef __amd64__
+#define	USE_SET
+#endif
+
 typedef void (*event_handler)(void);
 
 struct crash2_event {
@@ -67,7 +72,9 @@
 	event_handler ev_handler[NTHREADS];
 };
 
+#ifdef USE_SET
 SET_DECLARE(crash2_event_set, struct crash2_event);
+#endif
 
 #define CRASH2_EVENT(name, func, ...)					\
 	_CRASH2_EVENT(name, __LINE__, func , ## __VA_ARGS__)
@@ -78,8 +85,16 @@
 	    { name, { func , ## __VA_ARGS__ } };			\
 	DATA_SET(crash2_event_set, crash2_event_ ## line)
 
+#ifdef USE_SET
 #define	MAX_EVENT	SET_COUNT(crash2_event_set)
+#else
+#define	MAX_EVENT	event_max
+#endif
 
+#ifndef USE_SET
+static int event_max;
+static struct crash2_event **event_start, **event_stop;
+#endif
 static struct cv event_cv;
 static struct mtx event_mtx;
 static struct proc *kthread[NTHREADS];
@@ -164,11 +179,19 @@
 {
 	struct crash2_event **ev;
 
+#ifdef USE_SET
 	SET_FOREACH(ev, crash2_event_set) {
+#else
+	for (ev = event_start; ev < event_stop; ev++) {
+#endif
 		/* Skip null event 0. */
 		if ((*ev)->ev_name == NULL)
 			continue;
+#ifdef USE_SET
 		printf("%4td  %s\n", ev - SET_BEGIN(crash2_event_set),
+#else
+		printf("%4td  %s\n", ev - event_start,
+#endif
 		    (*ev)->ev_name);
 	}
 }
@@ -240,7 +263,11 @@
 			printf("crash2[%d]: event %d is not defined!\n", i, ev);
 			continue;
 		}
+#ifdef USE_SET
 		evp = SET_ITEM(crash2_event_set, ev);
+#else
+		evp = event_start[ev];
+#endif
 		if (evp->ev_handler[i])
 			evp->ev_handler[i]();		
 		mtx_lock(&event_mtx);
@@ -317,6 +344,12 @@
 
 	switch (cmd) {
 	case MOD_LOAD:
+#ifndef USE_SET
+		error = linker_file_lookup_set(module_file(module),
+		    "crash2_event_set", &event_start, &event_stop, &event_max);
+		if (error)
+			break;
+#endif
 		error = load(arg);
 		break;
 	case MOD_UNLOAD:


More information about the p4-projects mailing list