Re: [PATCH v5 2/4] tools/include/uapi: Add __kernel_old_time_t typedef to tools/include/uapi/linux/time_types.h
From: Thomas Weißschuh
Date: Mon Aug 31 2026 - 05:15:53 EST
On Sat, Aug 29, 2026 at 05:14:52PM +0800, wang.yaxin@xxxxxxxxxx wrote:
> From: Wang Yaxin <wang.yaxin@xxxxxxxxxx>
>
> Add time_types.h to tools/include/uapi/ to enable y2038-safe time
> structures in tools. Unlike the kernel's uapi version, we define
> the required types directly instead of including
> <asm-generic/posix_types.h>.
This reads, like the UAPI variant uses asm-generic/posix_types.h, which
it doesn't.
> Rationale:
> - asm-generic/posix_types.h is NOT architecture-independent
> - Different architectures override types (e.g., x86_32 overrides
> __kernel_mode_t, __kernel_uid_t, __kernel_gid_t to unsigned short)
> - int-ll64.h is special and cannot be used as a pattern here
>
> Direct typedefs for the three types actually needed:
> - __kernel_long_t: base type for time values
> - __kernel_time64_t: 64-bit time for y2038-safe interfaces
> - __kernel_old_time_t: legacy time type introduced in v5.5
>
> This follows the reviewer's suggestion to add typedefs only where
> needed, avoiding architecture-specific issues while maintaining
> self-containment of tools/include/uapi/.
>
> Signed-off-by: Wang Yaxin <wang.yaxin@xxxxxxxxxx>
> ---
> tools/include/uapi/linux/time_types.h | 76 +++++++++++++++++++++++++++
> 1 file changed, 76 insertions(+)
> create mode 100644 tools/include/uapi/linux/time_types.h
>
> diff --git a/tools/include/uapi/linux/time_types.h b/tools/include/uapi/linux/time_types.h
> new file mode 100644
> index 000000000000..3aa25d824cac
> --- /dev/null
> +++ b/tools/include/uapi/linux/time_types.h
> @@ -0,0 +1,76 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> +/* Started by AICoder, pid:00350371 */
> +#ifndef _UAPI_LINUX_TIME_TYPES_H
> +#define _UAPI_LINUX_TIME_TYPES_H
> +
> +#include <linux/types.h>
> +
> +/*
> + * Define time-related types directly instead of including
> + * <asm-generic/posix_types.h>. The asm-generic header is not
> + * architecture-independent: different architectures override
> + * certain types (e.g., x86_32 overrides __kernel_mode_t, __kernel_uid_t,
> + * __kernel_gid_t to unsigned short).
> + *
> + * We only need a few specific types here, so define them directly
> + * to avoid architecture-specific issues while maintaining self-containment.
> + */
> +
> +#ifndef __kernel_long_t
> +typedef long __kernel_long_t;
> +#endif
__kernel_long_t itself is from 2012. Can we not rely on it?
I thought only __kernel_old_time_t was the problem.
__kernel_long_t is architecture-dependent, so this could now be wrong with
old UAPI headers. If it is not strictly needed, I would just drop this.
> +#ifndef __kernel_time64_t
This type is never #defined, so the guard is pointless.
> +typedef long long __kernel_time64_t;
Is __kernel_time64_t a problem with your UAPI headers currently?
It is older than __kernel_old_time_t. If not, I would drop this.
> +#endif
> +
> +/*
> + * __kernel_old_time_t was introduced in v5.5 for y2038-safe migration.
> + * It is used by legacy time structures like __kernel_old_timespec.
> + * Defined here to avoid dependency on outdated system headers.
> + */
> +#ifndef __kernel_old_time_t
This type is never #defined, so the guard is pointless.
> +typedef __kernel_long_t __kernel_old_time_t;
> +#endif
> +/* Ended by AICoder, pid:00350371 */
Hm, what is this supposed to do? Also missing "Assisted-by" tag?
(...)