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


The following commit(s) were added to refs/heads/master by this push:
     new bc7c520eca drivers/note: add note_syscall_enter parameter list
bc7c520eca is described below

commit bc7c520ecad1de70ea2102e6af3a9056e0f6d343
Author: yinshengkai <[email protected]>
AuthorDate: Thu Dec 29 14:43:20 2022 +0800

    drivers/note: add note_syscall_enter parameter list
    
    Signed-off-by: yinshengkai <[email protected]>
---
 drivers/note/note_driver.c       | 27 ++++++++++++++++-----------
 include/nuttx/note/note_driver.h |  6 ++++--
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/note/note_driver.c b/drivers/note/note_driver.c
index c35c117df2..7dfc192e20 100644
--- a/drivers/note/note_driver.c
+++ b/drivers/note/note_driver.c
@@ -71,10 +71,12 @@
 #define note_spinlock(drv, tcb, spinlock, type)                              \
   ((drv)->ops->spinlock &&                                                   \
   ((drv)->ops->spinlock(drv, tcb, spinlock, type), true))
-#define note_syscall_enter(drv, nr)                                          \
-  ((drv)->ops->syscall_enter && ((drv)->ops->syscall_enter(drv, nr), true))
-#define note_syscall_leave(drv, nr)                                          \
-  ((drv)->ops->syscall_leave && ((drv)->ops->syscall_leave(drv, nr), true))
+#define note_syscall_enter(drv, nr, argc, ap)                                \
+  ((drv)->ops->syscall_enter &&                                              \
+  ((drv)->ops->syscall_enter(drv, nr, argc, ap), true))
+#define note_syscall_leave(drv, nr, result)                                  \
+  ((drv)->ops->syscall_leave &&                                              \
+  ((drv)->ops->syscall_leave(drv, nr, result), true))
 #define note_irqhandler(drv, irq, handler, enter)                            \
   ((drv)->ops->irqhandler &&                                                 \
   ((drv)->ops->irqhandler(drv, irq, handler, enter), true))
@@ -1184,13 +1186,18 @@ void sched_note_syscall_enter(int nr, int argc, ...)
     }
 #endif
 
+  va_start(ap, argc);
   for (driver = g_note_drivers; *driver; driver++)
     {
-      if (note_syscall_enter(*driver, nr))
+      va_list copy;
+      va_copy(copy, ap);
+      if (note_syscall_enter(*driver, nr, argc, &copy))
         {
+          va_end(copy);
           continue;
         }
 
+      va_end(copy);
       if ((*driver)->ops->add == NULL)
         {
           continue;
@@ -1210,23 +1217,21 @@ void sched_note_syscall_enter(int nr, int argc, ...)
 
           /* If needed, retrieve the given syscall arguments */
 
-          va_start(ap, argc);
-
           args = note.nsc_args;
           for (i = 0; i < argc; i++)
             {
-              arg = (uintptr_t)va_arg(ap, uintptr_t);
+              arg = (uintptr_t)va_arg(copy, uintptr_t);
               sched_note_flatten(args, &arg, sizeof(arg));
               args += sizeof(uintptr_t);
             }
-
-          va_end(ap);
         }
 
       /* Add the note to circular buffer */
 
       note_add(*driver, &note, length);
     }
+
+    va_end(ap);
 }
 
 void sched_note_syscall_leave(int nr, uintptr_t result)
@@ -1243,7 +1248,7 @@ void sched_note_syscall_leave(int nr, uintptr_t result)
 
   for (driver = g_note_drivers; *driver; driver++)
     {
-      if (note_syscall_leave(*driver, nr))
+      if (note_syscall_leave(*driver, nr, result))
         {
           continue;
         }
diff --git a/include/nuttx/note/note_driver.h b/include/nuttx/note/note_driver.h
index fc3f31a44e..8a2f8ad810 100644
--- a/include/nuttx/note/note_driver.h
+++ b/include/nuttx/note/note_driver.h
@@ -78,8 +78,10 @@ struct note_driver_ops_s
                         FAR volatile void *spinlock, int type);
 #endif
 #ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL
-  CODE void (*syscall_enter)(FAR struct note_driver_s *drv, int nr);
-  CODE void (*syscall_leave)(FAR struct note_driver_s *drv, int nr);
+  CODE void (*syscall_enter)(FAR struct note_driver_s *drv,
+                             int nr, int argc, va_list *ap);
+  CODE void (*syscall_leave)(FAR struct note_driver_s *drv,
+                             int nr, uintptr_t result);
 #endif
 #ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER
   CODE void (*irqhandler)(FAR struct note_driver_s *drv, int irq,

Reply via email to