[PATCH 05/12] kern_tc.c: Replace atomic functions required by PPS API

Gabriel Moyano gabriel.moyano at dlr.de
Thu Apr 7 08:36:00 UTC 2022


---
 cpukit/include/sys/timepps.h | 4 ++++
 cpukit/score/src/kern_tc.c   | 7 +++++++
 2 files changed, 11 insertions(+)

diff --git a/cpukit/include/sys/timepps.h b/cpukit/include/sys/timepps.h
index 621afb08ec..5703381ffa 100644
--- a/cpukit/include/sys/timepps.h
+++ b/cpukit/include/sys/timepps.h
@@ -32,7 +32,11 @@
 
 typedef int pps_handle_t;	
 
+#ifndef __rtems__
 typedef unsigned pps_seq_t;
+#else /* __rtems__ */
+typedef Atomic_Uint	pps_seq_t;
+#endif /* __rtems__ */
 
 typedef struct ntp_fp {
 	unsigned int	integral;
diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c
index e57da2c0ca..77f7a9212c 100644
--- a/cpukit/score/src/kern_tc.c
+++ b/cpukit/score/src/kern_tc.c
@@ -1932,10 +1932,17 @@ pps_fetch(struct pps_fetch_args *fapi, struct pps_state *pps)
 			tv.tv_usec = fapi->timeout.tv_nsec / 1000;
 			timo = tvtohz(&tv);
 		}
+#ifndef __rtems__
 		aseq = atomic_load_int(&pps->ppsinfo.assert_sequence);
 		cseq = atomic_load_int(&pps->ppsinfo.clear_sequence);
 		while (aseq == atomic_load_int(&pps->ppsinfo.assert_sequence) &&
 		    cseq == atomic_load_int(&pps->ppsinfo.clear_sequence)) {
+#else /* __rtems__ */
+		aseq = atomic_load_acq_int(&pps->ppsinfo.assert_sequence);
+		cseq = atomic_load_acq_int(&pps->ppsinfo.clear_sequence);
+		while (aseq == atomic_load_acq_int(&pps->ppsinfo.assert_sequence) &&
+		    cseq == atomic_load_acq_int(&pps->ppsinfo.clear_sequence)) {
+#endif /* __rtems__ */
 			if (abi_aware(pps, 1) && pps->driver_mtx != NULL) {
 				if (pps->flags & PPSFLAG_MTX_SPIN) {
 					err = msleep_spin(pps, pps->driver_mtx,
-- 
2.25.1



More information about the devel mailing list