Date: Mon, 5 Jun 2017 12:00:26 -0500 From: Pedro Giffuni <pfg@FreeBSD.org> To: Eric van Gyzen <vangyzen@FreeBSD.org> Cc: FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: Re: Function attribute for optimization level Message-ID: <0e9c89aa-920f-26bb-abde-2f4901740933@FreeBSD.org> In-Reply-To: <ec177111-2dae-f1c3-034f-df9f65c30da2@FreeBSD.org> References: <ec177111-2dae-f1c3-034f-df9f65c30da2@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 04/06/2017 23:08, Pedro Giffuni wrote: > > Hi Eric; > > It is a good idea : the nonopt attribute is useful in parts of the > boot loader and probably in security-related functions. > > >> diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h >> index 9cdc03c861cb..e370f6d6459e 100644 >> --- a/sys/sys/cdefs.h >> +++ b/sys/sys/cdefs.h >> @@ -396,6 +396,14 @@ >> #define __unreachable() ((void)0) >> #endif >> >> +#if __has_attribute(optnone) >> +#define __no_optimization __attribute__((optnone)) >> +#elif __has_attribute(optimize) >> +#define __no_optimization __attribute__((optimize(0))) >> +#else >> +#define __no_optimization >> +#endif > > I think the second one is wrong though: 'optimize' doesn't appear to > be a valid clang attribute. GCC uses an optimize("O0") pragma, but it > is not an attribute and __has_attribute doesn't work for GCC anyways. > Bah, I found it in the GCC 4.4 Release Notes. Fopr GCC you have to check __GNUC_PREREQ__(4, 4) instead __has_attribute(). Cheers, Pedro.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0e9c89aa-920f-26bb-abde-2f4901740933>