Re: [PATCH] tools/nolibc: support nanoseconds in stat()

From: Willy Tarreau
Date: Sun May 28 2023 - 03:37:44 EST


On Sat, May 27, 2023 at 02:56:42PM +0200, Thomas Weißschuh wrote:
> Keep backwards compatibility through unions.
>
> The compatibility macros like
>
> #define st_atime st_atim.tv_sec
>
> as documented in stat(3type) don't work for nolibc because it would
> break with other stat-like structures that contain the field st_atime.

Ah, good idea, I like this approach. Generally speaking I hate defining
macros to access some struct members, even though it has been done for
decades in various places of standard libs. Your solution making use of
anonymous unions is an elegant alternative to this.

Thanks!
Willy