You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/10/13 06:05:59 UTC

(nuttx) 03/13: note: merge nc_systime_nsec and sec

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

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

commit c018be66bd755f2508feee9f665c69c5498644d5
Author: yinshengkai <yi...@xiaomi.com>
AuthorDate: Mon Feb 5 15:27:08 2024 +0800

    note: merge nc_systime_nsec and sec
    
    Signed-off-by: yinshengkai <yi...@xiaomi.com>
---
 drivers/note/note_driver.c    |  6 +-----
 drivers/note/noteram_driver.c |  6 +++---
 include/nuttx/sched_note.h    | 11 ++---------
 3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/note/note_driver.c b/drivers/note/note_driver.c
index 218e3443f3..1476058334 100644
--- a/drivers/note/note_driver.c
+++ b/drivers/note/note_driver.c
@@ -224,9 +224,6 @@ static void note_common(FAR struct tcb_s *tcb,
                         FAR struct note_common_s *note,
                         uint8_t length, uint8_t type)
 {
-  struct timespec ts;
-  perf_convert(perf_gettime(), &ts);
-
   /* Save all of the common fields */
 
   note->nc_length = length;
@@ -244,8 +241,7 @@ static void note_common(FAR struct tcb_s *tcb,
       note->nc_pid = tcb->pid;
     }
 
-  note->nc_systime_sec = ts.tv_sec;
-  note->nc_systime_nsec = ts.tv_nsec;
+  note->nc_systime = perf_gettime();
 }
 
 /****************************************************************************
diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c
index f111c8fdc7..79b7d5dfbd 100644
--- a/drivers/note/noteram_driver.c
+++ b/drivers/note/noteram_driver.c
@@ -649,11 +649,11 @@ static int noteram_dump_header(FAR struct lib_outstream_s *s,
                                FAR struct note_common_s *note,
                                FAR struct noteram_dump_context_s *ctx)
 {
+  struct timespec ts;
   pid_t pid;
-  long nsec = note->nc_systime_nsec;
-  time_t sec = note->nc_systime_sec;
   int ret;
 
+  perf_convert(note->nc_systime, &ts);
   pid = note->nc_pid;
 #ifdef CONFIG_SMP
   int cpu = note->nc_cpu;
@@ -663,7 +663,7 @@ static int noteram_dump_header(FAR struct lib_outstream_s *s,
 
   ret = lib_sprintf(s, "%8s-%-3u [%d] %3" PRIu64 ".%09lu: ",
                     get_taskname(pid), get_pid(pid), cpu,
-                    (uint64_t)sec, nsec);
+                    (uint64_t)ts.tv_sec, ts.tv_nsec);
 
   return ret;
 }
diff --git a/include/nuttx/sched_note.h b/include/nuttx/sched_note.h
index 18f78598fd..3d755e0abf 100644
--- a/include/nuttx/sched_note.h
+++ b/include/nuttx/sched_note.h
@@ -320,15 +320,8 @@ struct note_common_s
   uint8_t nc_type;             /* See enum note_type_e */
   uint8_t nc_priority;         /* Thread/task priority */
   uint8_t nc_cpu;              /* CPU thread/task running on */
-  pid_t nc_pid;                /* ID of the thread/task */
-
-  /* Time when note was buffered (sec) */
-
-  time_t nc_systime_sec;
-
-  /* Time when note was buffered (nsec) */
-
-  long nc_systime_nsec;
+  pid_t   nc_pid;              /* ID of the thread/task */
+  clock_t nc_systime;          /* Time when note was buffered */
 };
 
 /* This is the specific form of the NOTE_START note */