[rtems commit] score: Remove superfluous timecounter members

Sebastian Huber sebh at rtems.org
Wed Oct 2 05:02:51 UTC 2019


Module:    rtems
Branch:    master
Commit:    2763f530d37ce6583dabac928c56172d931a8be0
Changeset: http://git.rtems.org/rtems/commit/?id=2763f530d37ce6583dabac928c56172d931a8be0

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Oct  1 12:41:47 2019 +0200

score: Remove superfluous timecounter members

---

 cpukit/include/sys/timetc.h               |  4 +++-
 cpukit/score/src/kern_tc.c                | 10 +++++++---
 testsuites/sptests/sptimecounter01/init.c |  4 ++--
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/cpukit/include/sys/timetc.h b/cpukit/include/sys/timetc.h
index 347a140..5cdfdfe 100644
--- a/cpukit/include/sys/timetc.h
+++ b/cpukit/include/sys/timetc.h
@@ -45,12 +45,14 @@ typedef uint32_t timecounter_fill_vdso_timehands32_t(struct vdso_timehands32 *,
 
 struct timecounter {
 	timecounter_get_t	*tc_get_timecount;
+#ifndef __rtems__
 		/*
 		 * This function reads the counter.  It is not required to
 		 * mask any unimplemented bits out, as long as they are
 		 * constant.
 		 */
 	timecounter_pps_t	*tc_poll_pps;
+#endif /* __rtems__ */
 		/*
 		 * This function is optional.  It will be called whenever the
 		 * timecounter is rewound, and is intended to check for PPS
@@ -64,6 +66,7 @@ struct timecounter {
 	const char		*tc_name;
 		/* Name of the timecounter. */
 	int			tc_quality;
+#ifndef __rtems__
 		/*
 		 * Used to determine if this timecounter is better than
 		 * another timecounter higher means better.  Negative
@@ -80,7 +83,6 @@ struct timecounter {
 		/* Pointer to the timecounter's private parts. */
 	struct timecounter	*tc_next;
 		/* Pointer to the next timecounter. */
-#ifndef __rtems__
 	timecounter_fill_vdso_timehands_t *tc_fill_vdso_timehands;
 	timecounter_fill_vdso_timehands32_t *tc_fill_vdso_timehands32;
 #endif /* __rtems__ */
diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index d705b59..082cb9f 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -146,7 +146,11 @@ dummy_get_timecount(struct timecounter *tc)
 }
 
 static struct timecounter dummy_timecounter = {
+#ifndef __rtems__
 	dummy_get_timecount, 0, ~0u, 1000000, "dummy", -1000000
+#else /* __rtems__ */
+	dummy_get_timecount, ~(uint32_t)0, 1000000, "dummy", -1000000
+#endif /* __rtems__ */
 };
 
 struct timehands {
@@ -195,9 +199,9 @@ static struct timehands th0 = {
 
 static struct timehands *volatile timehands = &th0;
 struct timecounter *timecounter = &dummy_timecounter;
+#ifndef __rtems__
 static struct timecounter *timecounters = &dummy_timecounter;
 
-#ifndef __rtems__
 int tc_min_ticktock_freq = 1;
 #endif /* __rtems__ */
 
@@ -1359,11 +1363,9 @@ tc_init(struct timecounter *tc)
 		    tc->tc_name, (uintmax_t)tc->tc_frequency,
 		    tc->tc_quality);
 	}
-#endif /* __rtems__ */
 
 	tc->tc_next = timecounters;
 	timecounters = tc;
-#ifndef __rtems__
 	/*
 	 * Set up sysctl tree for this counter.
 	 */
@@ -1566,6 +1568,7 @@ _Timecounter_Windup(struct bintime *new_boottimebin,
 	}
 	bintime_addx(&th->th_offset, th->th_scale * delta);
 
+#ifndef __rtems__
 	/*
 	 * Hardware latching timecounters may not generate interrupts on
 	 * PPS events, so instead we poll them.  There is a finite risk that
@@ -1576,6 +1579,7 @@ _Timecounter_Windup(struct bintime *new_boottimebin,
 	 */
 	if (tho->th_counter->tc_poll_pps)
 		tho->th_counter->tc_poll_pps(tho->th_counter);
+#endif /* __rtems__ */
 
 	/*
 	 * Deal with NTP second processing.  The for loop normally
diff --git a/testsuites/sptests/sptimecounter01/init.c b/testsuites/sptests/sptimecounter01/init.c
index 6976f7b..9fc3658 100644
--- a/testsuites/sptests/sptimecounter01/init.c
+++ b/testsuites/sptests/sptimecounter01/init.c
@@ -38,8 +38,9 @@ static test_context test_instance;
 
 static uint32_t test_get_timecount_soft(struct timecounter *tc)
 {
-  test_context *ctx = tc->tc_priv;
+  test_context *ctx;
 
+  ctx = RTEMS_CONTAINER_OF(tc, test_context, tc_soft);
   ++ctx->tc_soft_counter;
 
   return ctx->tc_soft_counter;
@@ -124,7 +125,6 @@ void boot_card(const char *cmdline)
   tc_soft->tc_counter_mask = 0x0fffffff;
   tc_soft->tc_frequency = soft_freq;
   tc_soft->tc_quality = 1234;
-  tc_soft->tc_priv = ctx;
   _Timecounter_Install(tc_soft);
   assert(ctx->tc_soft_counter == 3);
 



More information about the vc mailing list