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 7699dde25dc8069299b0e116d532e9b544939240
Author: Marco Casaroli <[email protected]>
AuthorDate: Fri Oct 23 05:48:07 2026 +0200

    include/nuttx/semaphore.h: Hide nuttx/clock.h with NUTTX_NO_EXTENSIONS.
    
    <stdio.h> and <pthread.h> include nuttx/mutex.h, which includes
    nuttx/semaphore.h, which includes nuttx/clock.h and nuttx/lib/math32.h.
    So every program gets about 130 NuttX macros with generic names, for
    example TM_YEAR_BASE, SEC_PER_MIN, NSEC_PER_SEC, FLS() and
    div_round_up().  A program with "enum { TM_YEAR_BASE = 1900 };", for
    example, does not compile.
    
    nuttx/semaphore.h itself needs only clockid_t and uint32_t from them.
    Include <stdint.h> and <time.h> for those, and include nuttx/clock.h
    only without NUTTX_NO_EXTENSIONS.  The OS, its libraries and the
    applications in the tree, which use the clock helpers through this
    header, do not change.
    
    nuttx/mm/mm.h calls memset() in mm_initialize(), but it got <string.h>
    only through nuttx/clock.h.  Include <string.h> there.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 include/nuttx/mm/mm.h     |  1 +
 include/nuttx/semaphore.h | 11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/nuttx/mm/mm.h b/include/nuttx/mm/mm.h
index 3f3b9d57db2..2dc84918f88 100644
--- a/include/nuttx/mm/mm.h
+++ b/include/nuttx/mm/mm.h
@@ -33,6 +33,7 @@
 #include <sys/types.h>
 #include <stdbool.h>
 #include <malloc.h>
+#include <string.h>
 
 /****************************************************************************
  * Pre-processor Definitions
diff --git a/include/nuttx/semaphore.h b/include/nuttx/semaphore.h
index 5cce87701f8..93966690f34 100644
--- a/include/nuttx/semaphore.h
+++ b/include/nuttx/semaphore.h
@@ -31,8 +31,17 @@
 
 #include <errno.h>
 #include <semaphore.h>
+#include <stdint.h>
+#include <time.h>
 
-#include <nuttx/clock.h>
+/* The OS and its libraries get the clock helpers here.  A program that
+ * defines NUTTX_NO_EXTENSIONS does not: <stdio.h> and <pthread.h> include
+ * this file, and nuttx/clock.h defines names such as TM_YEAR_BASE.
+ */
+
+#ifndef NUTTX_NO_EXTENSIONS
+#  include <nuttx/clock.h>
+#endif
 
 /****************************************************************************
  * Pre-processor Definitions

Reply via email to