Re: [PATCH 04/12] tools/nolibc: use attribute((naked)) if available

From: Willy Tarreau
Date: Sat Aug 03 2024 - 14:33:18 EST


On Sat, Aug 03, 2024 at 08:28:08PM +0200, Thomas Weißschuh wrote:
> > I think that it can resolve to roughly this:
> >
> > #if defined(__has_attribute) && __has_attribute(naked)
> > #  define __entrypoint __attribute__((naked))
> > #  define __entrypoint_epilogue()
> > #else
> > #  define __entrypoint __attribute__((optimize("Os", "omit-frame-pointer")))
> > #  define __entrypoint_epilogue() __builtin_unreachable()
> > #endif
>
> We would need to duplicate the define for the
> !defined(__has_attribute) case.

I don't understand why. Above both are tested on the first line.
Am I missing something ?

> I wanted to avoid that duplication.
> > What do you think ?
>
> With the reasoning above I'll let you choose.

I'm fine with avoiding duplication, I just don't understand why there
should be.

Willy