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

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

commit ddb87d3b86ab9a5b358b2244815117db9a4d708c
Author: yinshengkai <[email protected]>
AuthorDate: Thu Sep 28 16:37:27 2023 +0800

    clock: replace all up_perf_xx with perf_xx
    
    Signed-off-by: yinshengkai <[email protected]>
    Signed-off-by: Xiang Xiao <[email protected]>
---
 drivers/note/note_driver.c      | 13 +++----------
 drivers/note/notesnap_driver.c  | 31 +++++++------------------------
 drivers/rptun/rptun_ping.c      | 16 ++++++++--------
 drivers/segger/note_sysview.c   |  4 ++--
 fs/procfs/fs_procfscritmon.c    |  4 ++--
 fs/procfs/fs_procfsproc.c       |  8 ++++----
 include/limits.h                |  6 ++++++
 include/nuttx/sched.h           | 18 +++++++++---------
 sched/Kconfig                   |  8 --------
 sched/clock/clock_gettime.c     |  4 ++--
 sched/irq/irq.h                 |  9 ++-------
 sched/irq/irq_attach.c          |  6 +-----
 sched/irq/irq_dispatch.c        | 37 +++++++------------------------------
 sched/irq/irq_procfs.c          | 15 +++++----------
 sched/sched/sched_critmonitor.c | 31 ++++++++++++++++---------------
 sched/wdog/wd_start.c           | 12 ++++++------
 sched/wqueue/kwork_thread.c     | 12 ++++++------
 17 files changed, 86 insertions(+), 148 deletions(-)

diff --git a/drivers/note/note_driver.c b/drivers/note/note_driver.c
index 229a2a9d12..6e7ae4d677 100644
--- a/drivers/note/note_driver.c
+++ b/drivers/note/note_driver.c
@@ -234,20 +234,13 @@ static void note_common(FAR struct tcb_s *tcb,
                         FAR struct note_common_s *note,
                         uint8_t length, uint8_t type)
 {
-#ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT
-  struct timespec perftime;
-#endif
   struct timespec ts;
-  clock_systime_timespec(&ts);
-#ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT
-  up_perf_convert(up_perf_gettime(), &perftime);
-  ts.tv_nsec = perftime.tv_nsec;
-#endif
+  perf_convert(perf_gettime(), &ts);
 
   /* Save all of the common fields */
 
-  note->nc_length   = length;
-  note->nc_type     = type;
+  note->nc_length = length;
+  note->nc_type   = type;
 
   if (tcb == NULL)
     {
diff --git a/drivers/note/notesnap_driver.c b/drivers/note/notesnap_driver.c
index c288de8d10..dfce652958 100644
--- a/drivers/note/notesnap_driver.c
+++ b/drivers/note/notesnap_driver.c
@@ -41,11 +41,7 @@ struct notesnap_chunk_s
   uint8_t cpu;
 #endif
   pid_t pid;
-#ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT
-  unsigned long count;
-#else
-  struct timespec time;
-#endif
+  clock_t count;
   uintptr_t args;
 };
 
@@ -216,11 +212,7 @@ static inline void notesnap_common(FAR struct 
note_driver_s *drv,
 #ifdef CONFIG_SMP
   note->cpu = tcb->cpu;
 #endif
-#ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT
-  note->count = up_perf_gettime();
-#else
-  clock_systime_timespec(&note->time);
-#endif
+  note->count = perf_gettime();
   note->pid = tcb->pid;
   note->args = args;
 }
@@ -379,14 +371,11 @@ void notesnap_dump_with_stream(FAR struct lib_outstream_s 
*stream)
 {
   size_t i;
   size_t index = g_notesnap.index % CONFIG_DRIVERS_NOTESNAP_NBUFFERS;
-
-#ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT
-  uint32_t lastcount = g_notesnap.buffer[index].count;
+  clock_t lastcount = g_notesnap.buffer[index].count;
   struct timespec lasttime =
   {
     0
   };
-#endif
 
   /* Stop recording while dumping */
 
@@ -397,15 +386,13 @@ void notesnap_dump_with_stream(FAR struct lib_outstream_s 
*stream)
     {
       FAR struct notesnap_chunk_s *note = &g_notesnap.buffer[i];
 
-#ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT
       struct timespec time;
-      unsigned long elapsed = note->count < lastcount ?
-                         note->count + UINT32_MAX - lastcount :
-                         note->count - lastcount;
-      up_perf_convert(elapsed, &time);
+      clock_t elapsed = note->count < lastcount ?
+                        note->count + CLOCK_MAX - lastcount :
+                        note->count - lastcount;
+      perf_convert(elapsed, &time);
       clock_timespec_add(&lasttime, &time, &lasttime);
       lastcount = note->count;
-#endif
 
       lib_sprintf(stream,
                   "snapshoot: [%u.%09u] "
@@ -413,12 +400,8 @@ void notesnap_dump_with_stream(FAR struct lib_outstream_s 
*stream)
                   "[CPU%d] "
 #endif
                   "[%d] %-16s %#" PRIxPTR "\n",
-#ifdef CONFIG_SCHED_INSTRUMENTATION_PERFCOUNT
                   (unsigned)lasttime.tv_sec,
                   (unsigned)lasttime.tv_nsec,
-#else
-                  (unsigned)note->time.tv_sec, (unsigned)note->time.tv_nsec,
-#endif
 #ifdef CONFIG_SMP
                   note->cpu,
 #endif
diff --git a/drivers/rptun/rptun_ping.c b/drivers/rptun/rptun_ping.c
index 5215d4d6d7..3146d4ed95 100644
--- a/drivers/rptun/rptun_ping.c
+++ b/drivers/rptun/rptun_ping.c
@@ -28,6 +28,7 @@
 #include <inttypes.h>
 #include <string.h>
 #include <sys/param.h>
+#include <time.h>
 
 #include "rptun.h"
 
@@ -121,11 +122,11 @@ static int rptun_ping_once(FAR struct rpmsg_endpoint *ept,
   return ret;
 }
 
-static void rptun_ping_logout(FAR const char *s, unsigned long value)
+static void rptun_ping_logout(FAR const char *s, clock_t value)
 {
   struct timespec ts;
 
-  up_perf_convert(value, &ts);
+  perf_convert(value, &ts);
 
 #ifdef CONFIG_SYSTEM_TIME64
   syslog(LOG_INFO, "%s: s %" PRIu64 ", ns %ld\n", s, ts.tv_sec, ts.tv_nsec);
@@ -141,8 +142,8 @@ static void rptun_ping_logout(FAR const char *s, unsigned 
long value)
 int rptun_ping(FAR struct rpmsg_endpoint *ept,
                FAR const struct rptun_ping_s *ping)
 {
-  unsigned long min = ULONG_MAX;
-  unsigned long max = 0;
+  clock_t min = ULONG_MAX;
+  clock_t max = 0;
   uint64_t total = 0;
   int i;
 
@@ -153,7 +154,7 @@ int rptun_ping(FAR struct rpmsg_endpoint *ept,
 
   for (i = 0; i < ping->times; i++)
     {
-      unsigned long tm = up_perf_gettime();
+      clock_t tm = perf_gettime();
 
       int ret = rptun_ping_once(ept, ping->len, ping->ack);
       if (ret < 0)
@@ -161,7 +162,7 @@ int rptun_ping(FAR struct rpmsg_endpoint *ept,
           return ret;
         }
 
-      tm     = up_perf_gettime() - tm;
+      tm     = perf_gettime() - tm;
       min    = MIN(min, tm);
       max    = MAX(max, tm);
       total += tm;
@@ -169,8 +170,7 @@ int rptun_ping(FAR struct rpmsg_endpoint *ept,
       usleep(ping->sleep * USEC_PER_MSEC);
     }
 
-  syslog(LOG_INFO, "current CPU freq: %lu, ping times: %d\n",
-                    up_perf_getfreq(), ping->times);
+  syslog(LOG_INFO, "ping times: %d\n", ping->times);
 
   rptun_ping_logout("avg", total / ping->times);
   rptun_ping_logout("min", min);
diff --git a/drivers/segger/note_sysview.c b/drivers/segger/note_sysview.c
index 808570fa14..807ee225eb 100644
--- a/drivers/segger/note_sysview.c
+++ b/drivers/segger/note_sysview.c
@@ -350,7 +350,7 @@ unsigned int note_sysview_get_interrupt_id(void)
 
 unsigned long note_sysview_get_timestamp(void)
 {
-  return up_perf_gettime();
+  return perf_gettime();
 }
 
 /****************************************************************************
@@ -369,7 +369,7 @@ unsigned long note_sysview_get_timestamp(void)
 
 int note_sysview_initialize(void)
 {
-  unsigned long freq = up_perf_getfreq();
+  unsigned long freq = perf_getfreq();
   int ret;
 
   static const SEGGER_SYSVIEW_OS_API g_sysview_trace_api =
diff --git a/fs/procfs/fs_procfscritmon.c b/fs/procfs/fs_procfscritmon.c
index 02a92cee38..b904fe77ee 100644
--- a/fs/procfs/fs_procfscritmon.c
+++ b/fs/procfs/fs_procfscritmon.c
@@ -191,7 +191,7 @@ static ssize_t critmon_read_cpu(FAR struct critmon_file_s 
*attr,
 
   if (g_premp_max[cpu] > 0)
     {
-      up_perf_convert(g_premp_max[cpu], &maxtime);
+      perf_convert(g_premp_max[cpu], &maxtime);
     }
   else
     {
@@ -222,7 +222,7 @@ static ssize_t critmon_read_cpu(FAR struct critmon_file_s 
*attr,
 
   if (g_crit_max[cpu] > 0)
     {
-      up_perf_convert(g_crit_max[cpu], &maxtime);
+      perf_convert(g_crit_max[cpu], &maxtime);
     }
   else
     {
diff --git a/fs/procfs/fs_procfsproc.c b/fs/procfs/fs_procfsproc.c
index d590ce94e0..a443e50b40 100644
--- a/fs/procfs/fs_procfsproc.c
+++ b/fs/procfs/fs_procfsproc.c
@@ -775,7 +775,7 @@ static ssize_t proc_critmon(FAR struct proc_file_s 
*procfile,
 
   if (tcb->premp_max > 0)
     {
-      up_perf_convert(tcb->premp_max, &maxtime);
+      perf_convert(tcb->premp_max, &maxtime);
     }
   else
     {
@@ -808,7 +808,7 @@ static ssize_t proc_critmon(FAR struct proc_file_s 
*procfile,
 
   if (tcb->crit_max > 0)
     {
-      up_perf_convert(tcb->crit_max, &maxtime);
+      perf_convert(tcb->crit_max, &maxtime);
     }
   else
     {
@@ -841,7 +841,7 @@ static ssize_t proc_critmon(FAR struct proc_file_s 
*procfile,
 
   if (tcb->run_max > 0)
     {
-      up_perf_convert(tcb->run_max, &maxtime);
+      perf_convert(tcb->run_max, &maxtime);
     }
   else
     {
@@ -852,7 +852,7 @@ static ssize_t proc_critmon(FAR struct proc_file_s 
*procfile,
   /* Reset the maximum */
 
   tcb->run_max = 0;
-  up_perf_convert(tcb->run_time, &runtime);
+  perf_convert(tcb->run_time, &runtime);
 
   /* Output the maximum time the thread has run and
    * the total time the thread has run
diff --git a/include/limits.h b/include/limits.h
index c0f8017f27..13bb91d2a4 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -232,6 +232,12 @@
 #define TIMER_MAX      _POSIX_TIMER_MAX
 #define CLOCKRES_MIN   _POSIX_CLOCKRES_MIN
 
+#ifdef CONFIG_SYSTEM_TIME64
+#  define CLOCK_MAX    UINT64_MAX
+#else
+#  define CLOCK_MAX    UINT32_MAX
+#endif
+
 /* Other invariant values */
 
 /* CHARCLASS_NAME_MAX
diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index cb1715ce15..f50125e86c 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -631,13 +631,13 @@ struct tcb_s
   /* Pre-emption monitor support ********************************************/
 
 #ifdef CONFIG_SCHED_CRITMONITOR
-  unsigned long premp_start;             /* Time when preemption disabled   */
-  unsigned long premp_max;               /* Max time preemption disabled    */
-  unsigned long crit_start;              /* Time critical section entered   */
-  unsigned long crit_max;                /* Max time in critical section    */
-  unsigned long run_start;               /* Time when thread begin run      */
-  unsigned long run_max;                 /* Max time thread run             */
-  unsigned long run_time;                /* Total time thread run           */
+  clock_t premp_start;             /* Time when preemption disabled   */
+  clock_t premp_max;               /* Max time preemption disabled    */
+  clock_t crit_start;              /* Time critical section entered   */
+  clock_t crit_max;                /* Max time in critical section    */
+  clock_t run_start;               /* Time when thread begin run      */
+  clock_t run_max;                 /* Max time thread run             */
+  clock_t run_time;                /* Total time thread run           */
 #endif
 
   /* State save areas *******************************************************/
@@ -762,8 +762,8 @@ extern "C"
 #ifdef CONFIG_SCHED_CRITMONITOR
 /* Maximum time with pre-emption disabled or within critical section. */
 
-EXTERN unsigned long g_premp_max[CONFIG_SMP_NCPUS];
-EXTERN unsigned long g_crit_max[CONFIG_SMP_NCPUS];
+EXTERN clock_t g_premp_max[CONFIG_SMP_NCPUS];
+EXTERN clock_t g_crit_max[CONFIG_SMP_NCPUS];
 #endif /* CONFIG_SCHED_CRITMONITOR */
 
 EXTERN const struct tcbinfo_s g_tcbinfo;
diff --git a/sched/Kconfig b/sched/Kconfig
index 98db23a2b6..fd7a02eead 100644
--- a/sched/Kconfig
+++ b/sched/Kconfig
@@ -1080,14 +1080,6 @@ config SCHED_INSTRUMENTATION_CPUSET
        ---help---
                Monitor only CPUs in the bitset.  Bit 0=CPU0, Bit1=CPU1, etc.
 
-config SCHED_INSTRUMENTATION_PERFCOUNT
-       bool "Use perf count for instrumentation"
-       default n
-       ---help---
-               Enabling this option will use perfcount as the clock source for 
tv_nsec
-               to achieve higher precision time.
-               This requires calling up_perf_init at system startup.
-
 config SCHED_INSTRUMENTATION_FILTER
        bool "Instrumentation filter"
        default n
diff --git a/sched/clock/clock_gettime.c b/sched/clock/clock_gettime.c
index 1c5f3f5384..0dffa8ae13 100644
--- a/sched/clock/clock_gettime.c
+++ b/sched/clock/clock_gettime.c
@@ -155,7 +155,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
 
       if (tcb != NULL)
         {
-          up_perf_convert(tcb->run_time, tp);
+          perf_convert(tcb->run_time, tp);
         }
       else
         {
@@ -197,7 +197,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
             }
 
           leave_critical_section(flags);
-          up_perf_convert(runtime, tp);
+          perf_convert(runtime, tp);
         }
       else
         {
diff --git a/sched/irq/irq.h b/sched/irq/irq.h
index 43d495b2be..7088249c5d 100644
--- a/sched/irq/irq.h
+++ b/sched/irq/irq.h
@@ -60,13 +60,8 @@ struct irq_info_s
   FAR void *arg;     /* The argument provided to the interrupt handler. */
 #ifdef CONFIG_SCHED_IRQMONITOR
   clock_t start;     /* Time interrupt attached */
-#ifdef CONFIG_HAVE_LONG_LONG
-  uint64_t count;    /* Number of interrupts on this IRQ */
-#else
-  uint32_t mscount;  /* Number of interrupts on this IRQ (MS) */
-  uint32_t lscount;  /* Number of interrupts on this IRQ (LS) */
-#endif
-  uint32_t time;     /* Maximum execution time on this IRQ */
+  clock_t time;      /* Maximum execution time on this IRQ */
+  uint32_t count;    /* Number of interrupts on this IRQ */
 #endif
 };
 
diff --git a/sched/irq/irq_attach.c b/sched/irq/irq_attach.c
index a51ce0ac90..0ca62f0238 100644
--- a/sched/irq/irq_attach.c
+++ b/sched/irq/irq_attach.c
@@ -117,12 +117,8 @@ int irq_attach(int irq, xcpt_t isr, FAR void *arg)
       g_irqvector[ndx].arg     = arg;
 #ifdef CONFIG_SCHED_IRQMONITOR
       g_irqvector[ndx].start   = clock_systime_ticks();
-#ifdef CONFIG_HAVE_LONG_LONG
+      g_irqvector[ndx].time    = 0;
       g_irqvector[ndx].count   = 0;
-#else
-      g_irqvector[ndx].mscount = 0;
-      g_irqvector[ndx].lscount = 0;
-#endif
 #endif
 
       leave_critical_section(flags);
diff --git a/sched/irq/irq_dispatch.c b/sched/irq/irq_dispatch.c
index 7533ce7ad1..55732248ae 100644
--- a/sched/irq/irq_dispatch.c
+++ b/sched/irq/irq_dispatch.c
@@ -45,29 +45,6 @@
 #  define NUSER_IRQS NR_IRQS
 #endif
 
-/* INCR_COUNT - Increment the count of interrupts taken on this IRQ number */
-
-#ifndef CONFIG_SCHED_IRQMONITOR
-#  define INCR_COUNT(ndx)
-#elif defined(CONFIG_HAVE_LONG_LONG)
-#  define INCR_COUNT(ndx) \
-     do \
-       { \
-         g_irqvector[ndx].count++; \
-       } \
-     while (0)
-#else
-#  define INCR_COUNT(ndx) \
-     do \
-       { \
-         if (++g_irqvector[ndx].lscount == 0) \
-           { \
-             g_irqvector[ndx].mscount++; \
-           } \
-       } \
-     while (0)
-#endif
-
 /* CALL_VECTOR - Call the interrupt service routine attached to this
  * interrupt request
  */
@@ -80,14 +57,14 @@
 #  define CALL_VECTOR(ndx, vector, irq, context, arg) \
      do \
        { \
-         unsigned long start; \
-         unsigned long elapsed; \
-         start = up_perf_gettime(); \
+         clock_t start; \
+         clock_t elapsed; \
+         start = perf_gettime(); \
          vector(irq, context, arg); \
-         elapsed = up_perf_gettime() - start; \
+         elapsed = perf_gettime() - start; \
          if (ndx < NUSER_IRQS) \
            { \
-             INCR_COUNT(ndx); \
+             g_irqvector[ndx].count++; \
              if (elapsed > g_irqvector[ndx].time) \
                { \
                  g_irqvector[ndx].time = elapsed; \
@@ -96,8 +73,8 @@
          if (CONFIG_SCHED_CRITMONITOR_MAXTIME_IRQ > 0 && \
              elapsed > CONFIG_SCHED_CRITMONITOR_MAXTIME_IRQ) \
            { \
-             CRITMONITOR_PANIC("IRQ %d(%p), execute time too long %lu\n", \
-                               irq, vector, elapsed); \
+             CRITMONITOR_PANIC("IRQ %d(%p), execute time too long %ju\n", \
+                               irq, vector, (uintmax_t)elapsed); \
            } \
        } \
      while (0)
diff --git a/sched/irq/irq_procfs.c b/sched/irq/irq_procfs.c
index e3065e1fcc..7f5618579a 100644
--- a/sched/irq/irq_procfs.c
+++ b/sched/irq/irq_procfs.c
@@ -159,15 +159,10 @@ static int irq_callback(int irq, FAR struct irq_info_s 
*info,
 
   flags = enter_critical_section();
   memcpy(&copy, info, sizeof(struct irq_info_s));
-  now           = clock_systime_ticks();
-  info->start   = now;
-#ifdef CONFIG_HAVE_LONG_LONG
-  info->count   = 0;
-#else
-  info->mscount = 0;
-  info->lscount = 0;
-#endif
-  info->time    = 0;
+  now         = clock_systime_ticks();
+  info->start = now;
+  info->time  = 0;
+  info->count = 0;
   leave_critical_section(flags);
 
   /* Don't bother if count == 0.
@@ -201,7 +196,7 @@ static int irq_callback(int irq, FAR struct irq_info_s 
*info,
    */
 
   elapsed = now - copy.start;
-  up_perf_convert(copy.time, &delta);
+  perf_convert(copy.time, &delta);
 
 #ifdef CONFIG_HAVE_LONG_LONG
   /* elapsed = <current-time> - <start-time>, units=clock ticks
diff --git a/sched/sched/sched_critmonitor.c b/sched/sched/sched_critmonitor.c
index f296d75913..de9c38b47d 100644
--- a/sched/sched/sched_critmonitor.c
+++ b/sched/sched/sched_critmonitor.c
@@ -28,6 +28,7 @@
 #include <sched.h>
 #include <assert.h>
 #include <debug.h>
+#include <time.h>
 
 #include "sched/sched.h"
 
@@ -103,8 +104,8 @@
 
 /* Start time when pre-emption disabled or critical section entered. */
 
-static unsigned long g_premp_start[CONFIG_SMP_NCPUS];
-static unsigned long g_crit_start[CONFIG_SMP_NCPUS];
+static clock_t g_premp_start[CONFIG_SMP_NCPUS];
+static clock_t g_crit_start[CONFIG_SMP_NCPUS];
 
 /****************************************************************************
  * Public Data
@@ -112,8 +113,8 @@ static unsigned long g_crit_start[CONFIG_SMP_NCPUS];
 
 /* Maximum time with pre-emption disabled or within critical section. */
 
-unsigned long g_premp_max[CONFIG_SMP_NCPUS];
-unsigned long g_crit_max[CONFIG_SMP_NCPUS];
+clock_t g_premp_max[CONFIG_SMP_NCPUS];
+clock_t g_crit_max[CONFIG_SMP_NCPUS];
 
 /****************************************************************************
  * Public Functions
@@ -141,15 +142,15 @@ void nxsched_critmon_preemption(FAR struct tcb_s *tcb, 
bool state)
     {
       /* Disabling.. Save the thread start time */
 
-      tcb->premp_start   = up_perf_gettime();
+      tcb->premp_start   = perf_gettime();
       g_premp_start[cpu] = tcb->premp_start;
     }
   else
     {
       /* Re-enabling.. Check for the max elapsed time */
 
-      unsigned long now     = up_perf_gettime();
-      unsigned long elapsed = now - tcb->premp_start;
+      clock_t now     = perf_gettime();
+      clock_t elapsed = now - tcb->premp_start;
 
       if (elapsed > tcb->premp_max)
         {
@@ -189,15 +190,15 @@ void nxsched_critmon_csection(FAR struct tcb_s *tcb, bool 
state)
     {
       /* Entering... Save the start time. */
 
-      tcb->crit_start   = up_perf_gettime();
+      tcb->crit_start   = perf_gettime();
       g_crit_start[cpu] = tcb->crit_start;
     }
   else
     {
       /* Leaving .. Check for the max elapsed time */
 
-      unsigned long now     = up_perf_gettime();
-      unsigned long elapsed = now - tcb->crit_start;
+      clock_t now     = perf_gettime();
+      clock_t elapsed = now - tcb->crit_start;
 
       if (elapsed > tcb->crit_max)
         {
@@ -230,9 +231,9 @@ void nxsched_critmon_csection(FAR struct tcb_s *tcb, bool 
state)
 
 void nxsched_resume_critmon(FAR struct tcb_s *tcb)
 {
-  unsigned long current = up_perf_gettime();
+  clock_t current = perf_gettime();
   int cpu = this_cpu();
-  unsigned long elapsed;
+  clock_t elapsed;
 
   tcb->run_start = current;
 
@@ -294,11 +295,11 @@ void nxsched_resume_critmon(FAR struct tcb_s *tcb)
 
 void nxsched_suspend_critmon(FAR struct tcb_s *tcb)
 {
-  unsigned long current = up_perf_gettime();
-  unsigned long elapsed = current - tcb->run_start;
+  clock_t current = perf_gettime();
+  clock_t elapsed = current - tcb->run_start;
 
 #ifdef CONFIG_SCHED_CPULOAD_CRITMONITOR
-  unsigned long tick = elapsed * CLOCKS_PER_SEC / up_perf_getfreq();
+  clock_t tick = elapsed * CLOCKS_PER_SEC / perf_getfreq();
   nxsched_process_taskload_ticks(tcb, tick);
 #endif
 
diff --git a/sched/wdog/wd_start.c b/sched/wdog/wd_start.c
index cd031ca7d4..3a0fd5a831 100644
--- a/sched/wdog/wd_start.c
+++ b/sched/wdog/wd_start.c
@@ -52,16 +52,16 @@
 #  define CALL_FUNC(func, arg) \
      do \
        { \
-         unsigned long start; \
-         unsigned long elapsed; \
-         start = up_perf_gettime(); \
+         clock_t start; \
+         clock_t elapsed; \
+         start = perf_gettime(); \
          func(arg); \
-         elapsed = up_perf_gettime() - start; \
+         elapsed = perf_gettime() - start; \
          if (elapsed > CONFIG_SCHED_CRITMONITOR_MAXTIME_WDOG) \
            { \
-             CRITMONITOR_PANIC("WDOG %p, %s IRQ, execute too long %lu\n", \
+             CRITMONITOR_PANIC("WDOG %p, %s IRQ, execute too long %ju\n", \
                                func, up_interrupt_context() ? \
-                               "IN" : "NOT", elapsed); \
+                               "IN" : "NOT", (uintmax_t)elapsed); \
            } \
        } \
      while (0)
diff --git a/sched/wqueue/kwork_thread.c b/sched/wqueue/kwork_thread.c
index 9e2c8bf62d..a0a9ea5406 100644
--- a/sched/wqueue/kwork_thread.c
+++ b/sched/wqueue/kwork_thread.c
@@ -55,15 +55,15 @@
 #  define CALL_WORKER(worker, arg) \
      do \
        { \
-         unsigned long start; \
-         unsigned long elapsed; \
-         start = up_perf_gettime(); \
+         clock_t start; \
+         clock_t elapsed; \
+         start = perf_gettime(); \
          worker(arg); \
-         elapsed = up_perf_gettime() - start; \
+         elapsed = perf_gettime() - start; \
          if (elapsed > CONFIG_SCHED_CRITMONITOR_MAXTIME_WQUEUE) \
            { \
-             CRITMONITOR_PANIC("WORKER %p execute too long %lu\n", \
-                               worker, elapsed); \
+             CRITMONITOR_PANIC("WORKER %p execute too long %ju\n", \
+                               worker, (uintmax_t)elapsed); \
            } \
        } \
      while (0)

Reply via email to