tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: __dead functions



On Fri, Jul 18, 2008 at 17:51:13 +0300, Alexander Shishkin wrote:

> > So, from a quick look either this hunk is not necessary at all or it
> > should be replaced with an assertion.
> Or maybe an assertion can be placed right before __NOTREACHED?

It's better to fold the assertion into __NOTREACHED, as Jason suggests
in another followup, though I'd probably made that conditional on
DIAGNOSTIC.   


> > This should be protected with GCC_PREREQ I guess.
> Ok.
> +#if __GNUC_PREREQ__(4, 3)

gcc treats an infinite loop as "notreached" marker for quite some
time, may be even since gcc3.x, I don't remember.


#if __GNUC_PREREQ__(4, 0)       /* XXX: which version? */
#define __MARK_NOTREACHED for (;;) continue
#else
#define __MARK_NOTREACHED do {} while (/* CONSTCOND */ 0)
#define

#if defined(DIAGNOSTIC)
#define __NOTREACHED do {
        panic("%s:%d: %s reached NOTREACHED code", __func__, FILE, LINE);
        __MARK_NOTREACHED;
    } while (/* CONSTCOND */ 0)
#else
#define __NOTREACHED __MARK_NOTREACHED
#endif


PS: I wonder if do {} while (/* CONSTCOND */ 0) placeholder deserves a
canned macro.  We seem to use it quite a bit under ifdef __lint__ or
!DEBUG cases.

-uwe


Home | Main Index | Thread Index | Old Index