mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tools/nolibc: make time_t robust if __kernel_old_time_t is missing in host headers
@ 2025-09-18  1:08 Zhouyi Zhou
  2025-09-18 20:01 ` Thomas Weißschuh
  0 siblings, 1 reply; 2+ messages in thread
From: Zhouyi Zhou @ 2025-09-18  1:08 UTC (permalink / raw)
  To: w, linux, rcu, linux-kernel, lance; +Cc: Zhouyi Zhou

Commit 
d5094bcb5bfd ("tools/nolibc: define time_t in terms of __kernel_old_time_t")
made nolibc use the kernel's time type so that `time_t` matches
`timespec::tv_sec` on all ABIs (notably x32).    

Some distributions (e.g. Ubuntu 20.04 on ppc64le with older
exported headers under /usr/include) do not expose
`__kernel_old_time_t`, causing nolibc builds that rely on host
headers to fail (I discovered this when doing RCU torture test in
PPC VM of Open Source Lab of Oregon State University).
        
Keep the new behavior, but add a small compatibility shim:
if `__kernel_old_time_t` is not available, fall back to
 `signed long`

This preserves the intent of d5094bcb5bfd while letting nolibc
build on systems with older exported headers.

Fixes: d5094bcb5bfd ("tools/nolibc: define time_t in terms of __kernel_old_time_t")
Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com>    
---
 tools/include/nolibc/std.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h
index ba950f0e7338..ea225a0b16e9 100644
--- a/tools/include/nolibc/std.h
+++ b/tools/include/nolibc/std.h
@@ -29,6 +29,10 @@ typedef unsigned long       nlink_t;
 typedef   signed long         off_t;
 typedef   signed long     blksize_t;
 typedef   signed long      blkcnt_t;
+#ifndef __kernel_old_time_t
+typedef   signed long        time_t;
+#else
 typedef __kernel_old_time_t  time_t;
+#endif
 
 #endif /* _NOLIBC_STD_H */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-18 20:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-18  1:08 [PATCH] tools/nolibc: make time_t robust if __kernel_old_time_t is missing in host headers Zhouyi Zhou
2025-09-18 20:01 ` Thomas Weißschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®