You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/12/27 01:41:19 UTC

(nuttx) 01/02: fs: fix structure layout inconsistency in hostfs

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 9b102550885649834012bd25509cac4bd3e06d88
Author: yinshengkai <yi...@xiaomi.com>
AuthorDate: Tue Dec 26 23:52:50 2023 +0800

    fs: fix structure layout inconsistency in hostfs
    
    Use the following command to view the structure layout:
    pahole nuttx > struct_size.h
    
    Signed-off-by: yinshengkai <yi...@xiaomi.com>
---
 include/nuttx/fs/hostfs.h | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/include/nuttx/fs/hostfs.h b/include/nuttx/fs/hostfs.h
index cc175cbc45..af96c4fa9e 100644
--- a/include/nuttx/fs/hostfs.h
+++ b/include/nuttx/fs/hostfs.h
@@ -108,35 +108,41 @@
 /* These must match the definitions in include/sys/types.h */
 
 typedef int16_t      nuttx_blksize_t;
-#ifdef CONFIG_SMALL_MEMORY
+#  ifdef CONFIG_SMALL_MEMORY
 typedef int16_t      nuttx_gid_t;
 typedef int16_t      nuttx_uid_t;
-#else
+typedef uint16_t     nuttx_size_t;
+typedef int16_t      nuttx_ssize_t;
+#  else /* CONFIG_SMALL_MEMORY */
 typedef unsigned int nuttx_gid_t;
 typedef unsigned int nuttx_uid_t;
-#endif
+typedef uintptr_t    nuttx_size_t;
+typedef intptr_t     nuttx_ssize_t;
+#  endif /* CONFIG_SMALL_MEMORY */
 typedef uint32_t     nuttx_dev_t;
 typedef uint16_t     nuttx_ino_t;
 typedef uint16_t     nuttx_nlink_t;
-#ifdef CONFIG_FS_LARGEFILE
+#  ifdef CONFIG_FS_LARGEFILE
 typedef int64_t      nuttx_off_t;
 typedef uint64_t     nuttx_blkcnt_t;
-#else
+#  else
 typedef int32_t      nuttx_off_t;
 typedef uint32_t     nuttx_blkcnt_t;
-#endif
+#  endif
 typedef unsigned int nuttx_mode_t;
-typedef uintptr_t    nuttx_size_t;
-typedef intptr_t     nuttx_ssize_t;
 
 /* These must match the definition in include/time.h */
 
+#  ifdef CONFIG_SYSTEM_TIME64
+typedef int64_t      nuttx_time_t;
+#  else
 typedef uint32_t     nuttx_time_t;
+#  endif
 
 struct nuttx_timespec
 {
-    nuttx_time_t tv_sec;
-    long tv_nsec;
+  nuttx_time_t tv_sec;
+  long tv_nsec;
 };
 
 /* These must exactly match the definition from include/dirent.h: */