[PATCH v2 06/13] tools/nolibc: add pure 64bit off_t, time_t and blkcnt_t

Zhangjin Wu falcon at tinylab.org
Mon May 29 12:53:00 PDT 2023


clean up std.h with include/uapi/linux/posix_types.h

convert time_t to 64bit even in 32bit platforms, for y2038 issue.

align off_t and blkcnt_t with 'struct statx' in include/uapi/linux/stat.h

Suggested-by: Arnd Bergmann <arnd at arndb.de>
Link: https://lore.kernel.org/linux-riscv/83ab9f47-e1ed-463c-a717-26aad6bf2b71@app.fastmail.com/
Signed-off-by: Zhangjin Wu <falcon at tinylab.org>
---
 tools/include/nolibc/std.h | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h
index 933bc0be7e1c..0f458c1c24de 100644
--- a/tools/include/nolibc/std.h
+++ b/tools/include/nolibc/std.h
@@ -20,17 +20,21 @@
 
 #include "stdint.h"
 
-/* those are commonly provided by sys/types.h */
-typedef unsigned int          dev_t;
-typedef unsigned long         ino_t;
-typedef unsigned int         mode_t;
-typedef   signed int          pid_t;
-typedef unsigned int          uid_t;
-typedef unsigned int          gid_t;
-typedef unsigned long       nlink_t;
-typedef   signed long         off_t;
-typedef   signed long     blksize_t;
-typedef   signed long      blkcnt_t;
-typedef   signed long        time_t;
+#include <linux/posix_types.h>
+
+/* based on linux/types.h */
+typedef uint32_t __kernel_dev_t;
+
+typedef __kernel_dev_t          dev_t;
+typedef __kernel_ulong_t        ino_t;
+typedef __kernel_mode_t         mode_t;
+typedef __kernel_pid_t          pid_t;
+typedef __kernel_uid32_t        uid_t;
+typedef __kernel_gid32_t        gid_t;
+typedef __kernel_loff_t         off_t;
+typedef __kernel_time64_t       time_t;
+typedef uint32_t                nlink_t;
+typedef uint32_t                blksize_t;
+typedef uint64_t                blkcnt_t;
 
 #endif /* _NOLIBC_STD_H */
-- 
2.25.1




More information about the linux-riscv mailing list