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 <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2026-05-04 00:52:21 +08:00
committed by Xiang Xiao
parent 9ff99c6d0f
commit c020e6ef9a
9 changed files with 18 additions and 10 deletions
@@ -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,
@@ -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);
}
@@ -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 *);
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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 *);
+1 -1
View File
@@ -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);
}
@@ -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 *);
+1 -1
View File
@@ -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);
}
@@ -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 *);