Re: [PATCH RFC net-next 1/3] uapi: add INT_MAX and INT_MIN constants

From: Andrew Lunn
Date: Mon Jan 05 2026 - 09:52:34 EST


On Mon, Jan 05, 2026 at 09:26:47AM +0100, Thomas Weißschuh wrote:
> Some UAPI headers use INT_MAX and INT_MIN. Currently they include
> <limits.h> for their definitions, which introduces a problematic
> dependency on libc.
>
> Add custom, namespaced definitions of INT_MAX and INT_MIN using the
> same values as the regular kernel code.

Maybe a dumb question.

> +#define __KERNEL_INT_MAX ((int)(~0U >> 1))
> +#define __KERNEL_INT_MIN (-__KERNEL_INT_MAX - 1)

How does this work for a 32 bit userspace on top of a 64 bit kernel?

And do we need to be careful with KERNEL in the name, in that for a 32
bit userspace, this is going to be 32bit max int, when in fact the
kernel is using 64 bit max int?

Andrew