From 64ed0bb3072282265885689e1fe7e8baf3bb20c3 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 14 Jul 2016 14:55:49 +0200 Subject: score: Assert proper seqlock writer state Helps to detect invalid concurrent writes. --- cpukit/score/include/rtems/score/smplockseq.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cpukit/score/include/rtems/score/smplockseq.h') diff --git a/cpukit/score/include/rtems/score/smplockseq.h b/cpukit/score/include/rtems/score/smplockseq.h index 6fe7b7afa3..5daaee9c6e 100644 --- a/cpukit/score/include/rtems/score/smplockseq.h +++ b/cpukit/score/include/rtems/score/smplockseq.h @@ -21,6 +21,7 @@ #if defined(RTEMS_SMP) +#include #include #ifdef __cplusplus @@ -102,6 +103,8 @@ static inline unsigned int _SMP_sequence_lock_Write_begin( unsigned int seq; seq = _Atomic_Load_uint( &lock->sequence, ATOMIC_ORDER_RELAXED ); + _Assert( seq % 2 == 0 ); + _Atomic_Store_uint( &lock->sequence, seq + 1, ATOMIC_ORDER_RELAXED ); /* There is no atomic store with acquire/release semantics */ -- cgit v1.2.3