From owner-p4-projects@FreeBSD.ORG Wed Mar 29 23:10:18 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 12C2C16A422; Wed, 29 Mar 2006 23:10:18 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B730716A401 for ; Wed, 29 Mar 2006 23:10:17 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 69DDE43D49 for ; Wed, 29 Mar 2006 23:10:17 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k2TNAHde080210 for ; Wed, 29 Mar 2006 23:10:17 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k2TNAH6x080206 for perforce@freebsd.org; Wed, 29 Mar 2006 23:10:17 GMT (envelope-from jhb@freebsd.org) Date: Wed, 29 Mar 2006 23:10:17 GMT Message-Id: <200603292310.k2TNAH6x080206@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 94276 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Mar 2006 23:10:18 -0000 http://perforce.freebsd.org/chv.cgi?CH=94276 Change 94276 by jhb@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 #include #include +#include #include #include #include @@ -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: