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 9c82c8539a852ea91fcb03c2ebb7075b081da9da
Author: yinshengkai <[email protected]>
AuthorDate: Tue Jan 21 18:43:23 2025 +0800

    sched: move is_idle_task to nuttx/sched.h
    
    is_idle_task() was private to sched/, so code outside of the scheduler,
    e.g. in libs/libc, could not check whether it runs in an idle task.
    Move it to nuttx/sched.h.  It is only meaningful in the flat build and
    in the kernel; in user space it is false.
    
    Signed-off-by: yinshengkai <[email protected]>
---
 include/nuttx/sched.h | 6 ++++++
 sched/sched/sched.h   | 2 --
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index 31bfbdc3864..53e2ecba77a 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -234,6 +234,12 @@
 
 #define running_regs()               ((FAR void 
**)(g_running_tasks[this_cpu()]->xcp.regs))
 
+#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
+#  define is_idle_task(t)            ((t)->pid < CONFIG_SMP_NCPUS)
+#else
+#  define is_idle_task(t)            false
+#endif
+
 /****************************************************************************
  * Public Type Definitions
  ****************************************************************************/
diff --git a/sched/sched/sched.h b/sched/sched/sched.h
index 8780bb51470..3805fce8026 100644
--- a/sched/sched/sched.h
+++ b/sched/sched/sched.h
@@ -72,8 +72,6 @@
 #  define current_task(cpu)      ((FAR struct tcb_s *)list_readytorun()->head)
 #endif
 
-#define is_idle_task(t)          ((t)->pid < CONFIG_SMP_NCPUS)
-
 /* This macro returns the running task which may different from this_task()
  * during interrupt level context switches.
  */

Reply via email to