diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-11-18 16:47:21 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-11-19 08:44:24 +0100 |
commit | b71bb9ca9873c5e5c2b4b195d9d65c4972b047f2 (patch) | |
tree | c7c68d1ac0ebd52fa8c6ee6ec655bc628cb3d6e9 | |
parent | f5e087319411efc7971a7311e7b59f0c01b34090 (diff) |
testsuites/validation/tx-support.c
-rw-r--r-- | testsuites/validation/tx-support.c | 78 |
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( |