Date: Fri, 16 Jun 2000 21:58:49 -0700 (PDT) From: John Polstra <jdp@polstra.com> To: mjacob@feral.com Cc: hackers@freebsd.org Subject: Re: use of '#pragma weak...' Message-ID: <200006170458.VAA77459@vashon.polstra.com> In-Reply-To: <Pine.BSF.4.05.10006161530150.2928-100000@semuta.feral.com> References: <Pine.BSF.4.05.10006161530150.2928-100000@semuta.feral.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In article <Pine.BSF.4.05.10006161530150.2928-100000@semuta.feral.com>,
Matthew Jacob <mjacob@feral.com> 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 <sys/cdefs.h>. 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 <sys/cdefs.h>. 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200006170458.VAA77459>
