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 8f56040caa2ba3f7acf2523ec472532ee6fea080
Author: buxiasen <[email protected]>
AuthorDate: Sat Oct 11 20:48:12 2025 +0800

    percpu: remove all per_cpu_var use per_cpu_var_smp
    
    Use this_cpu for this_cpu_var to keep compatible with AMP
    Move this_cpu from sched.h to percpu.h for compatible issue
    
    No code in the tree uses per_cpu_var() yet, so only the macro
    definitions change.
    
    Signed-off-by: buxiasen <[email protected]>
---
 include/nuttx/percpu.h | 16 ++++++++++++----
 include/nuttx/sched.h  | 10 ----------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/include/nuttx/percpu.h b/include/nuttx/percpu.h
index 1647dd84268..e391e85da9b 100644
--- a/include/nuttx/percpu.h
+++ b/include/nuttx/percpu.h
@@ -33,25 +33,33 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
+/* These are macros to access the current CPU and the current task on a CPU.
+ * These macros are intended to support a future SMP implementation.
+ */
+
+#ifdef CONFIG_SMP
+#  define this_cpu()                   up_this_cpu()
+#else
+#  define this_cpu()                   (0)
+#endif
+
 #ifdef CONFIG_PERCPU_ARRAY
 #  define DEFINE_PER_CPU(t, v)         t v[CONFIG_NCPUS]
 #  define DEFINE_PER_CPU_BSS(t, v)     t v[CONFIG_NCPUS]
 #  define DECLARE_PER_CPU(t, v)        extern t v[CONFIG_NCPUS]
-#  define per_cpu_var(v, c)            v[c]
-#  define this_cpu_var(v)              per_cpu_var(v, up_cpu_index())
+#  define per_cpu_var_smp(v, c)        v[c]
+#  define this_cpu_var(v)              v[this_cpu()]
 #endif
 
 #ifdef CONFIG_SMP
 #  define DEFINE_PER_CPU_SMP(t, v)     DEFINE_PER_CPU(t, v)
 #  define DEFINE_PER_CPU_BSS_SMP(t, v) DEFINE_PER_CPU_BSS(t, v)
 #  define DECLARE_PER_CPU_SMP(t, v)    DECLARE_PER_CPU(t, v)
-#  define per_cpu_var_smp(v, c)        per_cpu_var(v, c)
 #  define this_cpu_var_smp(v)          this_cpu_var(v)
 #else
 #  define DEFINE_PER_CPU_SMP(t, v)     t v[1]
 #  define DEFINE_PER_CPU_BSS_SMP(t, v) t v[1]
 #  define DECLARE_PER_CPU_SMP(t, v)    extern t v[1]
-#  define per_cpu_var_smp(v, c)        v[0]
 #  define this_cpu_var_smp(v)          v[0]
 #endif
 
diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index 301c911d387..0271228e6da 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -238,16 +238,6 @@
 
 #define SMP_CALL_INITIALIZER(func, arg) {(func), (arg)}
 
-/* These are macros to access the current CPU and the current task on a CPU.
- * These macros are intended to support a future SMP implementation.
- */
-
-#ifdef CONFIG_SMP
-#  define this_cpu()                 up_this_cpu()
-#else
-#  define this_cpu()                 (0)
-#endif
-
 #define running_regs()               ((FAR void 
**)(g_running_tasks[this_cpu()]->xcp.regs))
 
 #if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)

Reply via email to