From owner-freebsd-hackers Fri Jun 16 21:58:55 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from wall.polstra.com (rtrwan160.accessone.com [206.213.115.74]) by hub.freebsd.org (Postfix) with ESMTP id ED93537BAAF for ; Fri, 16 Jun 2000 21:58:50 -0700 (PDT) (envelope-from jdp@polstra.com) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.9.3/8.9.3) with ESMTP id VAA15481; Fri, 16 Jun 2000 21:58:49 -0700 (PDT) (envelope-from jdp@polstra.com) From: John Polstra Received: (from jdp@localhost) by vashon.polstra.com (8.9.3/8.9.1) id VAA77459; Fri, 16 Jun 2000 21:58:49 -0700 (PDT) (envelope-from jdp@polstra.com) Date: Fri, 16 Jun 2000 21:58:49 -0700 (PDT) Message-Id: <200006170458.VAA77459@vashon.polstra.com> To: mjacob@feral.com Subject: Re: use of '#pragma weak...' In-Reply-To: References: Organization: Polstra & Co., Seattle, WA Cc: hackers@freebsd.org Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article , Matthew Jacob wrote: > > So, I notice that '#pragma weak' appears to work for me for the compilers and > linkers we currently use for i386 && alpha (at least in user space), so you > can do things like: > > --------- > extern void *isp_static_fw_vector(void); > #pragma weak isp_static_fw_vector [...] > Is there any reason to *not* use this trick in the kernel? I won't address the question of whether to use weak symbols in the kernel. But I do have an opinion about how it should be done if weak symbols are used. Instead of using "#pragma weak", make a macro "__weak_definition" or somesuch in . It should look something like this: #define __weak_definition __attribute__ ((__weak__)) and it should be enclosed in the appropriate #ifdefs to ensure that the compiler is GCC and its version is late enough to support it. See the other examples in . It would be used like this: extern void *isp_static_fw_vector(void) __weak_definition; #pragma weak is bad because you can't put #pragmas into macros. John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Disappointment is a good sign of basic intelligence." -- Chögyam Trungpa To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message