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

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

commit c020e6ef9af0377e46ba8e0e9ec62d0921f30dc2
Author: Xiang Xiao <[email protected]>
AuthorDate: Mon May 4 00:52:21 2026 +0800

    arch/esp32: Fix conflicting types for '_times_r'
    
    
D:/a/nuttx/nuttx/sources/nuttx/arch/risc-v/src/common/espressif/esp_libc_stubs.c:131:9:
 error: conflicting types for '_times_r'; have 'clock_t(struct _reent *, struct 
tms *)' {aka 'long long int(struct _reent *, struct tms *)'}
      131 | clock_t _times_r(struct _reent *r, struct tms *buf)
          |         ^~~~~~~~
    In file included from 
D:/a/nuttx/nuttx/sources/nuttx/build/arch/risc-v/src/common/espressif/esp-hal-3rdparty/components/esp_rom/esp32c3/include/esp32c3/rom/libc_stubs.h:15,
                     from 
D:/a/nuttx/nuttx/sources/nuttx/arch/risc-v/src/common/espressif/esp_libc_stubs.c:44:
    
D:/a/nuttx/nuttx/sources/tools/riscv-none-elf-gcc/riscv-none-elf/include/reent.h:156:18:
 note: previous declaration of '_times_r' with type 'long unsigned int(struct 
_reent *, struct tms *)'
      156 | extern _CLOCK_T_ _times_r (struct _reent *, struct tms *);
          |                  ^~~~~~~~
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 arch/risc-v/src/common/espressif/esp_libc_stubs.c       | 12 ++++++++++--
 arch/risc-v/src/esp32c3-legacy/esp32c3_libc_stubs.c     |  2 +-
 arch/risc-v/src/esp32c3-legacy/rom/esp32c3_libc_stubs.h |  2 +-
 arch/xtensa/src/esp32/esp32_libc_stubs.c                |  2 +-
 arch/xtensa/src/esp32/rom/esp32_libc_stubs.h            |  2 +-
 arch/xtensa/src/esp32s2/esp32s2_libc_stubs.c            |  2 +-
 arch/xtensa/src/esp32s2/rom/esp32s2_libc_stubs.h        |  2 +-
 arch/xtensa/src/esp32s3/esp32s3_libc_stubs.c            |  2 +-
 arch/xtensa/src/esp32s3/rom/esp32s3_libc_stubs.h        |  2 +-
 9 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/arch/risc-v/src/common/espressif/esp_libc_stubs.c 
b/arch/risc-v/src/common/espressif/esp_libc_stubs.c
index 5cfd85ccff7..307a2d78bfd 100644
--- a/arch/risc-v/src/common/espressif/esp_libc_stubs.c
+++ b/arch/risc-v/src/common/espressif/esp_libc_stubs.c
@@ -128,7 +128,7 @@ int _stat_r(struct _reent *r, const char *pathname, struct 
stat *statbuf)
   return nx_stat(pathname, statbuf, 1);
 }
 
-clock_t _times_r(struct _reent *r, struct tms *buf)
+unsigned long _times_r(struct _reent *r, struct tms *buf)
 {
   return times(buf);
 }
@@ -374,7 +374,15 @@ static const struct syscall_stub_table g_stub_table =
   ._abort = &_abort,
   ._system_r = &_system_r,
   ._rename_r = &_rename_r,
-  ._times_r = &_times_r,
+
+  /* The vendor ROM header declares ._times_r as 'clock_t (*)(...)' while
+   * newlib's <reent.h> prototypes _times_r() as returning 'unsigned long'.
+   * Since clock_t is now int64_t in NuttX, the two no longer match.  Cast
+   * here to silence -Wincompatible-pointer-types; the ROM only ever reads
+   * the low bits, so the truncation is harmless.
+   */
+
+  ._times_r = (clock_t (*)(struct _reent *, struct tms *))&_times_r,
   ._gettimeofday_r = &_gettimeofday_r,
   ._raise_r = &_raise_r,
   ._unlink_r = &_unlink_r,
diff --git a/arch/risc-v/src/esp32c3-legacy/esp32c3_libc_stubs.c 
b/arch/risc-v/src/esp32c3-legacy/esp32c3_libc_stubs.c
index b5afe3f9340..56ee3506cb4 100644
--- a/arch/risc-v/src/esp32c3-legacy/esp32c3_libc_stubs.c
+++ b/arch/risc-v/src/esp32c3-legacy/esp32c3_libc_stubs.c
@@ -121,7 +121,7 @@ int _stat_r(struct _reent *r, const char *pathname, struct 
stat *statbuf)
   return nx_stat(pathname, statbuf, 1);
 }
 
-clock_t _times_r(struct _reent *r, struct tms *buf)
+unsigned long _times_r(struct _reent *r, struct tms *buf)
 {
   return times(buf);
 }
diff --git a/arch/risc-v/src/esp32c3-legacy/rom/esp32c3_libc_stubs.h 
b/arch/risc-v/src/esp32c3-legacy/rom/esp32c3_libc_stubs.h
index 82d9c6a3296..b618e086d0e 100644
--- a/arch/risc-v/src/esp32c3-legacy/rom/esp32c3_libc_stubs.h
+++ b/arch/risc-v/src/esp32c3-legacy/rom/esp32c3_libc_stubs.h
@@ -56,7 +56,7 @@ struct syscall_stub_table
     void (* _abort)(void);
     int (* _system_r)(struct _reent *r, const char *);
     int (* _rename_r)(struct _reent *r, const char *, const char *);
-    clock_t (* _times_r)(struct _reent *r, struct tms *);
+    unsigned long (* _times_r)(struct _reent *r, struct tms *);
     int (* _gettimeofday_r) (struct _reent *r, struct timeval *, void *);
     void (* _raise_r)(struct _reent *r);
     int (* _unlink_r)(struct _reent *r, const char *);
diff --git a/arch/xtensa/src/esp32/esp32_libc_stubs.c 
b/arch/xtensa/src/esp32/esp32_libc_stubs.c
index 6adf18af0a1..7c69d40aa8c 100644
--- a/arch/xtensa/src/esp32/esp32_libc_stubs.c
+++ b/arch/xtensa/src/esp32/esp32_libc_stubs.c
@@ -114,7 +114,7 @@ int _stat_r(struct _reent *r, const char *pathname, struct 
stat *statbuf)
   return nx_stat(pathname, statbuf, 1);
 }
 
-clock_t _times_r(struct _reent *r, struct tms *buf)
+unsigned long _times_r(struct _reent *r, struct tms *buf)
 {
   return times(buf);
 }
diff --git a/arch/xtensa/src/esp32/rom/esp32_libc_stubs.h 
b/arch/xtensa/src/esp32/rom/esp32_libc_stubs.h
index 5ad98d3e4d8..4c96cb736e2 100644
--- a/arch/xtensa/src/esp32/rom/esp32_libc_stubs.h
+++ b/arch/xtensa/src/esp32/rom/esp32_libc_stubs.h
@@ -72,7 +72,7 @@ struct syscall_stub_table
   void (* _abort)(void);
   int (* _system_r)(struct _reent *r, const char *);
   int (* _rename_r)(struct _reent *r, const char *, const char *);
-  clock_t (* _times_r)(struct _reent *r, struct tms *);
+  unsigned long (* _times_r)(struct _reent *r, struct tms *);
   int (* _gettimeofday_r) (struct _reent *r, struct timeval *, void *);
   void (* _raise_r)(struct _reent *r);
   int (* _unlink_r)(struct _reent *r, const char *);
diff --git a/arch/xtensa/src/esp32s2/esp32s2_libc_stubs.c 
b/arch/xtensa/src/esp32s2/esp32s2_libc_stubs.c
index 9c61f6ef4f8..22b7b0b268d 100644
--- a/arch/xtensa/src/esp32s2/esp32s2_libc_stubs.c
+++ b/arch/xtensa/src/esp32s2/esp32s2_libc_stubs.c
@@ -114,7 +114,7 @@ int _stat_r(struct _reent *r, const char *pathname, struct 
stat *statbuf)
   return nx_stat(pathname, statbuf, 1);
 }
 
-clock_t _times_r(struct _reent *r, struct tms *buf)
+unsigned long _times_r(struct _reent *r, struct tms *buf)
 {
   return times(buf);
 }
diff --git a/arch/xtensa/src/esp32s2/rom/esp32s2_libc_stubs.h 
b/arch/xtensa/src/esp32s2/rom/esp32s2_libc_stubs.h
index fa6d95de4c0..2afdeb46ade 100644
--- a/arch/xtensa/src/esp32s2/rom/esp32s2_libc_stubs.h
+++ b/arch/xtensa/src/esp32s2/rom/esp32s2_libc_stubs.h
@@ -72,7 +72,7 @@ struct syscall_stub_table
   void (* _abort)(void);
   int (* _system_r)(struct _reent *r, const char *);
   int (* _rename_r)(struct _reent *r, const char *, const char *);
-  clock_t (* _times_r)(struct _reent *r, struct tms *);
+  unsigned long (* _times_r)(struct _reent *r, struct tms *);
   int (* _gettimeofday_r) (struct _reent *r, struct timeval *, void *);
   void (* _raise_r)(struct _reent *r);
   int (* _unlink_r)(struct _reent *r, const char *);
diff --git a/arch/xtensa/src/esp32s3/esp32s3_libc_stubs.c 
b/arch/xtensa/src/esp32s3/esp32s3_libc_stubs.c
index 0efe020acc8..690798e779a 100644
--- a/arch/xtensa/src/esp32s3/esp32s3_libc_stubs.c
+++ b/arch/xtensa/src/esp32s3/esp32s3_libc_stubs.c
@@ -116,7 +116,7 @@ int _stat_r(struct _reent *r, const char *pathname, struct 
stat *statbuf)
   return nx_stat(pathname, statbuf, 1);
 }
 
-clock_t _times_r(struct _reent *r, struct tms *buf)
+unsigned long _times_r(struct _reent *r, struct tms *buf)
 {
   return times(buf);
 }
diff --git a/arch/xtensa/src/esp32s3/rom/esp32s3_libc_stubs.h 
b/arch/xtensa/src/esp32s3/rom/esp32s3_libc_stubs.h
index c7cc0cb327d..4813f70e879 100644
--- a/arch/xtensa/src/esp32s3/rom/esp32s3_libc_stubs.h
+++ b/arch/xtensa/src/esp32s3/rom/esp32s3_libc_stubs.h
@@ -71,7 +71,7 @@ struct syscall_stub_table
     void (* _abort)(void);
     int (* _system_r)(struct _reent *r, const char *);
     int (* _rename_r)(struct _reent *r, const char *, const char *);
-    clock_t (* _times_r)(struct _reent *r, struct tms *);
+    unsigned long (* _times_r)(struct _reent *r, struct tms *);
     int (* _gettimeofday_r) (struct _reent *r, struct timeval *, void *);
     void (* _raise_r)(struct _reent *r);
     int (* _unlink_r)(struct _reent *r, const char *);

Reply via email to