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

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

commit 6c5f0559749b066f4054982e1c0c54b7c47036b1
Author: Marco Casaroli <[email protected]>
AuthorDate: Wed Oct 28 16:07:45 2026 +0100

    include/sys/types.h: Make struct timeval visible.
    
    glibc, musl and the BSDs make struct timeval visible through
    <sys/types.h> (glibc and musl through <sys/select.h> in their default
    mode), so <stdlib.h> also gives it.  Programs depend on that: CPython,
    for example, declares functions with struct timeval in an internal
    header without <sys/time.h>.  On NuttX the type is then declared inside
    the parameter list, and the definitions conflict with the declarations.
    
    Move the definition from <sys/time.h> to <sys/types.h>, which
    <sys/time.h> includes.  The layout does not change.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 include/sys/time.h  |  8 +-------
 include/sys/types.h | 11 +++++++++++
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/include/sys/time.h b/include/sys/time.h
index ec54bc35064..2a93e5ee736 100644
--- a/include/sys/time.h
+++ b/include/sys/time.h
@@ -128,13 +128,7 @@
 
 typedef clock_t hrtime_t;
 
-/* struct timeval represents time as seconds plus microseconds */
-
-struct timeval
-{
-  time_t tv_sec;         /* Seconds */
-  long tv_usec;          /* Microseconds */
-};
+/* struct timeval (seconds plus microseconds) is defined in <sys/types.h> */
 
 /* Type of the second argument to `getitimer' and
  * the second and third arguments `setitimer'.
diff --git a/include/sys/types.h b/include/sys/types.h
index afc4003ec0e..fb853f6f215 100644
--- a/include/sys/types.h
+++ b/include/sys/types.h
@@ -260,6 +260,17 @@ typedef FAR void    *timer_t;        /* Represents one 
POSIX timer */
 typedef uint32_t     useconds_t;
 typedef int32_t      suseconds_t;
 
+/* struct timeval represents time as seconds plus microseconds.  POSIX
+ * defines it in <sys/time.h> and <sys/select.h>; programs also expect it
+ * after <sys/types.h>.
+ */
+
+struct timeval
+{
+  time_t tv_sec;         /* Seconds */
+  long tv_usec;          /* Microseconds */
+};
+
 /* This is the smallest integer type that will hold a bitset of all CPUs */
 
 #if (CONFIG_SMP_NCPUS <= 32)

Reply via email to