Re: [PATCH v4 2/3] tools/accounting: factor out shared format_timespec() implementation

From: wang.yaxin

Date: Sat Aug 22 2026 - 05:52:04 EST


>> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
>> +#ifndef _TOOLS_UAPI_LINUX_TIME_TYPES_H
>> +#define _TOOLS_UAPI_LINUX_TIME_TYPES_H
>> +
>> +#include <linux/types.h>
>> +#include <asm/posix_types.h>
>
>So the tools/include/ header are supposed to be platform independent and standalone.
>But this relies on an asm/ header which itself is not part of tools/include/.
>The addition of this header did not remove the dependency on system UAPI headers.
>
>So why is this new header copy needed in its current form?

Thank you for identifying this issue. We agree that `#include <asm/posix_types.h>`
creates an undesirable dependency on system headers.

The problem: System headers (`/usr/include/asm-generic/posix_types.h`) are outdated
and lack `__kernel_old_time_t` (a y2038 fix added in the kernel). Simply removing
the include would cause compilation failures.

Our fix (two steps):

1. Change `time_types.h` to use `#include <asm-generic/posix_types.h>`
- This is architecture-independent: `asm-generic/posix_types.h` directly defines
all POSIX types (`__kernel_long_t`, `__kernel_time64_t`, `__kernel_old_time_t`)
without architecture-specific dispatching
- This follows the same pattern as `types.h` which uses `<asm-generic/int-ll64.h>`

2. Copy `include/uapi/asm-generic/posix_types.h` to `tools/include/uapi/asm-generic/`
- This restores the self-containment of tools/include/uapi/
- The copied file provides up-to-date type definitions (including y2038 fixes)
- No longer relies on outdated system headers

This addresses your concern by making `time_types.h` truly self-contained and
architecture-independent within tools/include/.

Thanks
Yaxin