summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-11-18 16:47:21 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-12-01 14:25:15 +0100
commitf0a70834c12a257372ad18ef09ecdb2a7d37186a (patch)
tree673437b5424e90f95e92c2215255d6d7a0ca1ad7
parentf77a22df0b4686aadde2e63ee240dfc8e2d8c4a7 (diff)
testsuites/validation/tx-support.c
-rw-r--r--testsuites/validation/tx-support.c78
1 files changed, 73 insertions, 5 deletions
diff --git a/testsuites/validation/tx-support.c b/testsuites/validation/tx-support.c
index 5e08f13526..fded29d429 100644
--- a/testsuites/validation/tx-support.c
+++ b/testsuites/validation/tx-support.c
@@ -891,16 +891,84 @@ void StopDelayThreadDispatch( uint32_t cpu_index )
#endif
}
+bool AreInterruptsEnabled( void )
+{
+ return _ISR_Get_level() == 0;
+}
+
+static bool IsWhiteSpace( char c )
+{
+ return c == ' ' || c == '\t';
+}
+
+bool IsWhiteSpaceOnly( const char *s )
+{
+ char c;
+
+ while ( ( c = *s ) != '\0' ) {
+ if ( !IsWhiteSpace( c ) ) {
+ return false;
+ }
+
+ ++s;
+ }
+
+ return true;
+}
+
+static const char *EatWhiteSpace( const char *s )
+{
+ char c;
+
+ while ( ( c = *s ) != '\0' ) {
+ if ( !IsWhiteSpace( c ) ) {
+ break;
+ }
+
+ ++s;
+ }
+
+ return s;
+}
+
+bool IsEqualIgnoreWhiteSpace( const char *a, const char *b )
+{
+ while ( true ) {
+ a = EatWhiteSpace( a );
+ b = EatWhiteSpace( b );
+
+ if ( *a != *b ) {
+ return false;
+ }
+
+ if ( *a == '\0' ) {
+ return true;
+ }
+
+ ++a;
+ ++b;
+ }
+
+ return true;
+}
+
#if defined(RTEMS_SMP)
-void TicketLockWaitForOwned( const SMP_ticket_lock_Control *lock )
+bool TicketLockIsAvailable( const SMP_ticket_lock_Control *lock )
{
unsigned int now_serving;
unsigned int next_ticket;
- do {
- now_serving = _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_RELAXED );
- next_ticket = _Atomic_Load_uint( &lock->next_ticket, ATOMIC_ORDER_RELAXED );
- } while ( now_serving == next_ticket );
+ now_serving = _Atomic_Load_uint( &lock->now_serving, ATOMIC_ORDER_RELAXED );
+ next_ticket = _Atomic_Load_uint( &lock->next_ticket, ATOMIC_ORDER_RELAXED );
+
+ return now_serving == next_ticket;
+}
+
+void TicketLockWaitForOwned( const SMP_ticket_lock_Control *lock )
+{
+ while ( TicketLockIsAvailable( lock ) ) {
+ /* Wait */
+ }
}
void TicketLockWaitForOthers(