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/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 764540267e sched/clock: Rename g_system_timer to g_system_ticks
764540267e is described below

commit 764540267e55c880be4ce281fc5e9444235cbb42
Author: Xiang Xiao <xiaoxi...@xiaomi.com>
AuthorDate: Tue Sep 27 12:03:48 2022 +0800

    sched/clock: Rename g_system_timer to g_system_ticks
    
    Signed-off-by: Xiang Xiao <xiaoxi...@xiaomi.com>
---
 Documentation/reference/os/time_clock.rst | 10 +++++-----
 arch/arm/src/lc823450/lc823450_timer.c    |  2 +-
 include/nuttx/clock.h                     |  8 ++++----
 sched/clock/clock.h                       |  8 ++------
 sched/clock/clock_initialize.c            | 10 +++++-----
 sched/clock/clock_systime_ticks.c         |  6 +++---
 6 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/Documentation/reference/os/time_clock.rst 
b/Documentation/reference/os/time_clock.rst
index f69372e96e..e47583ce54 100644
--- a/Documentation/reference/os/time_clock.rst
+++ b/Documentation/reference/os/time_clock.rst
@@ -11,9 +11,9 @@ by ``CONFIG_USEC_PER_TICK`` (default 10000 microseconds or 
100Hz.
 If ``CONFIG_SCHED_TICKLESS`` is selected, the default is 100
 microseconds). The timer generates an interrupt each
 ``CONFIG_USEC_PER_TICK`` microseconds and increments a counter
-called ``g_system_timer``. ``g_system_timer`` then provides a
+called ``g_system_ticks``. ``g_system_ticks`` then provides a
 time-base for calculating *up-time* and elapsed time intervals in
-units of ``CONFIG_USEC_PER_TICK``. The range of ``g_system_timer``
+units of ``CONFIG_USEC_PER_TICK``. The range of ``g_system_ticks``
 is, by default, 32-bits. However, if the MCU supports type
 ``long long`` and ``CONFIG_SYSTEM_TIME16`` is selected, a 64-bit
 system timer will be supported instead.
@@ -159,7 +159,7 @@ which requires the following base functions to read and set 
time:
 -  ``up_rtc_gettime()``. Get the current time from the high
    resolution RTC clock/counter. This interface is only supported
    by the high-resolution RTC/counter hardware implementation. It
-   is used to replace the system timer (``g_system_tick``).
+   is used to replace the system timer (``g_system_ticks``).
 -  ``up_rtc_settime()``. Set the RTC to the provided time. All RTC
    implementations must be able to set their time based on a
    standard timespec.
@@ -167,7 +167,7 @@ which requires the following base functions to read and set 
time:
 System Tick and Time
 ====================
 
-The system tick is represented by ``g_system_timer``.
+The system tick is represented by ``g_system_ticks``.
 
 Running at rate of system base timer, used for time-slicing, and
 so forth.
@@ -178,7 +178,7 @@ after successful initialization variables are overridden by 
calls
 to ``up_rtc_gettime()`` which is running continuously even in
 power-down modes.
 
-In the case of ``CONFIG_RTC_HIRES`` is set the ``g_system_timer``
+In the case of ``CONFIG_RTC_HIRES`` is set the ``g_system_ticks``
 keeps counting at rate of a system timer, which however, is
 disabled in power-down mode. By comparing this time and RTC
 (actual time) one may determine the actual system active time. To
diff --git a/arch/arm/src/lc823450/lc823450_timer.c 
b/arch/arm/src/lc823450/lc823450_timer.c
index 24ab57e0ce..00b10c9f87 100644
--- a/arch/arm/src/lc823450/lc823450_timer.c
+++ b/arch/arm/src/lc823450/lc823450_timer.c
@@ -700,7 +700,7 @@ int up_rtc_gettime(struct timespec *tp)
 
   /* Get the elapsed time */
 
-  elapsed = NSEC_PER_TICK * (uint64_t)g_system_timer;
+  elapsed = NSEC_PER_TICK * (uint64_t)g_system_ticks;
 
   /* Add the tiemr fraction in nanoseconds */
 
diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h
index d0b90157b4..fa04190fe1 100644
--- a/include/nuttx/clock.h
+++ b/include/nuttx/clock.h
@@ -240,11 +240,11 @@ extern "C"
  */
 
 #ifdef __HAVE_KERNEL_GLOBALS
-EXTERN volatile clock_t g_system_timer;
+EXTERN volatile clock_t g_system_ticks;
 
-#ifndef CONFIG_SYSTEM_TIME64
-#  define clock_systime_ticks() g_system_timer
-#endif
+#  ifndef CONFIG_SYSTEM_TIME64
+#    define clock_systime_ticks() g_system_ticks
+#  endif
 #endif
 
 /****************************************************************************
diff --git a/sched/clock/clock.h b/sched/clock/clock.h
index 632e672798..965dc98245 100644
--- a/sched/clock/clock.h
+++ b/sched/clock/clock.h
@@ -59,15 +59,11 @@
    * globally in include/nuttx/clock.h.
    */
 
-#  ifdef CONFIG_SYSTEM_TIME64
-extern volatile uint64_t g_system_timer;
-#  else
-extern volatile uint32_t g_system_timer;
-#  endif
+extern volatile clock_t g_system_ticks;
 #endif
 
 #ifndef CONFIG_CLOCK_TIMEKEEPING
-extern struct timespec   g_basetime;
+extern struct timespec  g_basetime;
 #endif
 
 /****************************************************************************
diff --git a/sched/clock/clock_initialize.c b/sched/clock/clock_initialize.c
index 090bdb7f08..f1f2a1f58c 100644
--- a/sched/clock/clock_initialize.c
+++ b/sched/clock/clock_initialize.c
@@ -49,9 +49,9 @@
 
 #ifndef CONFIG_SCHED_TICKLESS
 #ifdef CONFIG_SYSTEM_TIME64
-volatile uint64_t g_system_timer = INITIAL_SYSTEM_TIMER_TICKS;
+volatile uint64_t g_system_ticks = INITIAL_SYSTEM_TIMER_TICKS;
 #else
-volatile uint32_t g_system_timer = INITIAL_SYSTEM_TIMER_TICKS;
+volatile uint32_t g_system_ticks = INITIAL_SYSTEM_TIMER_TICKS;
 #endif
 #endif
 
@@ -394,8 +394,8 @@ void clock_resynchronize(FAR struct timespec *rtc_diff)
 
       /* Add the sleep time to correct system timer */
 
-      g_system_timer += SEC2TICK(rtc_diff->tv_sec);
-      g_system_timer += NSEC2TICK(rtc_diff->tv_nsec);
+      g_system_ticks += SEC2TICK(rtc_diff->tv_sec);
+      g_system_ticks += NSEC2TICK(rtc_diff->tv_nsec);
     }
 
 skip:
@@ -418,6 +418,6 @@ void clock_timer(void)
 {
   /* Increment the per-tick system counter */
 
-  g_system_timer++;
+  g_system_ticks++;
 }
 #endif
diff --git a/sched/clock/clock_systime_ticks.c 
b/sched/clock/clock_systime_ticks.c
index fb30eddae5..eaa9ef3c61 100644
--- a/sched/clock/clock_systime_ticks.c
+++ b/sched/clock/clock_systime_ticks.c
@@ -122,8 +122,8 @@ clock_t clock_systime_ticks(void)
 
   do
     {
-      verify = g_system_timer;
-      sample = g_system_timer;
+      verify = g_system_ticks;
+      sample = g_system_ticks;
     }
   while ((sample &  TIMER_MASK32)  < (verify &  TIMER_MASK32) ||
          (sample & ~TIMER_MASK32) != (verify & ~TIMER_MASK32));
@@ -134,7 +134,7 @@ clock_t clock_systime_ticks(void)
 
   /* Return the current system time */
 
-  return g_system_timer;
+  return g_system_ticks;
 
 # endif /* CONFIG_SYSTEM_TIME64 */
 #endif /* CONFIG_SCHED_TICKLESS */

Reply via email to