diff options
author | Gedare Bloom <gedare@rtems.org> | 2016-06-23 16:55:38 -0400 |
---|---|---|
committer | Gedare Bloom <gedare@rtems.org> | 2016-07-25 12:44:47 -0400 |
commit | b5bfaaf9c27996d672f7aad67fee24581ab2f218 (patch) | |
tree | 6504cee5972cd9003f5b36c58e4d94a020fde9fa /cpukit/posix | |
parent | posix: refactor cond wait support to defer abstime conversion (diff) | |
download | rtems-b5bfaaf9c27996d672f7aad67fee24581ab2f218.tar.bz2 |
posix: cond_timedwait remember and use clock from condattr
updates #2745
Diffstat (limited to 'cpukit/posix')
-rw-r--r-- | cpukit/posix/include/rtems/posix/cond.h | 1 | ||||
-rw-r--r-- | cpukit/posix/include/rtems/posix/condimpl.h | 4 | ||||
-rw-r--r-- | cpukit/posix/src/condinit.c | 2 | ||||
-rw-r--r-- | cpukit/posix/src/condtimedwait.c | 3 | ||||
-rw-r--r-- | cpukit/posix/src/condwaitsupp.c | 3 | ||||
-rw-r--r-- | cpukit/posix/src/mqueuetimedreceive.c | 2 | ||||
-rw-r--r-- | cpukit/posix/src/mqueuetimedsend.c | 2 | ||||
-rw-r--r-- | cpukit/posix/src/mutextimedlock.c | 2 | ||||
-rw-r--r-- | cpukit/posix/src/prwlocktimedrdlock.c | 2 | ||||
-rw-r--r-- | cpukit/posix/src/prwlocktimedwrlock.c | 2 | ||||
-rw-r--r-- | cpukit/posix/src/semtimedwait.c | 2 |
11 files changed, 16 insertions, 9 deletions
diff --git a/cpukit/posix/include/rtems/posix/cond.h b/cpukit/posix/include/rtems/posix/cond.h index 4fa7de7525..bbb80ef362 100644 --- a/cpukit/posix/include/rtems/posix/cond.h +++ b/cpukit/posix/include/rtems/posix/cond.h @@ -44,6 +44,7 @@ typedef struct { Objects_Control Object; Thread_queue_Control Wait_queue; pthread_mutex_t mutex; + clockid_t clock; } POSIX_Condition_variables_Control; #ifdef __cplusplus diff --git a/cpukit/posix/include/rtems/posix/condimpl.h b/cpukit/posix/include/rtems/posix/condimpl.h index dbeb6e1089..70a0707b8d 100644 --- a/cpukit/posix/include/rtems/posix/condimpl.h +++ b/cpukit/posix/include/rtems/posix/condimpl.h @@ -47,11 +47,13 @@ extern Objects_Information _POSIX_Condition_variables_Information; extern const pthread_condattr_t _POSIX_Condition_variables_Default_attributes; RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Initialize( - POSIX_Condition_variables_Control *the_cond + POSIX_Condition_variables_Control *the_cond, + pthread_condattr_t *the_attr ) { _Thread_queue_Initialize( &the_cond->Wait_queue ); the_cond->mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX; + the_cond->clock = the_attr->clock; } RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Destroy( diff --git a/cpukit/posix/src/condinit.c b/cpukit/posix/src/condinit.c index dde400f58d..e863dcd183 100644 --- a/cpukit/posix/src/condinit.c +++ b/cpukit/posix/src/condinit.c @@ -51,7 +51,7 @@ int pthread_cond_init( return ENOMEM; } - _POSIX_Condition_variables_Initialize( the_cond ); + _POSIX_Condition_variables_Initialize( the_cond, the_attr ); _Objects_Open_u32( &_POSIX_Condition_variables_Information, diff --git a/cpukit/posix/src/condtimedwait.c b/cpukit/posix/src/condtimedwait.c index 6c0b14f27b..1b338c8ae6 100644 --- a/cpukit/posix/src/condtimedwait.c +++ b/cpukit/posix/src/condtimedwait.c @@ -31,6 +31,9 @@ int pthread_cond_timedwait( const struct timespec *abstime ) { + if ( abstime == NULL ) { + return EINVAL; /* not specified */ + } return _POSIX_Condition_variables_Wait_support( cond, mutex, diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c index caa3a9af3d..92793ed3a4 100644 --- a/cpukit/posix/src/condwaitsupp.c +++ b/cpukit/posix/src/condwaitsupp.c @@ -65,7 +65,8 @@ int _POSIX_Condition_variables_Wait_support( * then we do a polling operation and convert the UNSATISFIED * status into the appropriate error. */ - status = _TOD_Absolute_timeout_to_ticks( abstime, &timeout ); + _Assert( the_cond->clock ); + status = _TOD_Absolute_timeout_to_ticks(abstime, the_cond->clock, &timeout); if ( status == TOD_ABSOLUTE_TIMEOUT_INVALID ) return EINVAL; diff --git a/cpukit/posix/src/mqueuetimedreceive.c b/cpukit/posix/src/mqueuetimedreceive.c index 19e5430ff2..f9b2730baa 100644 --- a/cpukit/posix/src/mqueuetimedreceive.c +++ b/cpukit/posix/src/mqueuetimedreceive.c @@ -76,7 +76,7 @@ ssize_t mq_timedreceive( * TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST, or TOD_ABSOLUTE_TIMEOUT_IS_NOW, * then we should not wait. */ - status = _TOD_Absolute_timeout_to_ticks( abstime, &ticks ); + status = _TOD_Absolute_timeout_to_ticks( abstime, CLOCK_REALTIME, &ticks ); if ( status != TOD_ABSOLUTE_TIMEOUT_IS_IN_FUTURE ) do_wait = false; diff --git a/cpukit/posix/src/mqueuetimedsend.c b/cpukit/posix/src/mqueuetimedsend.c index ce178fa08d..3920a3fcc1 100644 --- a/cpukit/posix/src/mqueuetimedsend.c +++ b/cpukit/posix/src/mqueuetimedsend.c @@ -56,7 +56,7 @@ int mq_timedsend( * TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST, or TOD_ABSOLUTE_TIMEOUT_IS_NOW, * then we should not wait. */ - status = _TOD_Absolute_timeout_to_ticks( abstime, &ticks ); + status = _TOD_Absolute_timeout_to_ticks( abstime, CLOCK_REALTIME, &ticks ); if ( status != TOD_ABSOLUTE_TIMEOUT_IS_IN_FUTURE ) do_wait = false; diff --git a/cpukit/posix/src/mutextimedlock.c b/cpukit/posix/src/mutextimedlock.c index c2f00785e2..cfc1827ae8 100644 --- a/cpukit/posix/src/mutextimedlock.c +++ b/cpukit/posix/src/mutextimedlock.c @@ -55,7 +55,7 @@ int pthread_mutex_timedlock( * TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST, or TOD_ABSOLUTE_TIMEOUT_IS_NOW, * then we should not wait. */ - status = _TOD_Absolute_timeout_to_ticks( abstime, &ticks ); + status = _TOD_Absolute_timeout_to_ticks( abstime, CLOCK_REALTIME, &ticks ); if ( status != TOD_ABSOLUTE_TIMEOUT_IS_IN_FUTURE ) do_wait = false; diff --git a/cpukit/posix/src/prwlocktimedrdlock.c b/cpukit/posix/src/prwlocktimedrdlock.c index c1a77e9b3c..623453073e 100644 --- a/cpukit/posix/src/prwlocktimedrdlock.c +++ b/cpukit/posix/src/prwlocktimedrdlock.c @@ -47,7 +47,7 @@ int pthread_rwlock_timedrdlock( * TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST, or TOD_ABSOLUTE_TIMEOUT_IS_NOW, * then we should not wait. */ - timeout_status = _TOD_Absolute_timeout_to_ticks( abstime, &ticks ); + timeout_status = _TOD_Absolute_timeout_to_ticks( abstime, CLOCK_REALTIME, &ticks ); do_wait = ( timeout_status == TOD_ABSOLUTE_TIMEOUT_IS_IN_FUTURE ); the_rwlock = _POSIX_RWLock_Get( rwlock, &queue_context ); diff --git a/cpukit/posix/src/prwlocktimedwrlock.c b/cpukit/posix/src/prwlocktimedwrlock.c index b7a9028a35..1fd57c0106 100644 --- a/cpukit/posix/src/prwlocktimedwrlock.c +++ b/cpukit/posix/src/prwlocktimedwrlock.c @@ -49,7 +49,7 @@ int pthread_rwlock_timedwrlock( * TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST, or TOD_ABSOLUTE_TIMEOUT_IS_NOW, * then we should not wait. */ - timeout_status = _TOD_Absolute_timeout_to_ticks( abstime, &ticks ); + timeout_status = _TOD_Absolute_timeout_to_ticks( abstime, CLOCK_REALTIME, &ticks ); do_wait = ( timeout_status == TOD_ABSOLUTE_TIMEOUT_IS_IN_FUTURE ); the_rwlock = _POSIX_RWLock_Get( rwlock, &queue_context ); diff --git a/cpukit/posix/src/semtimedwait.c b/cpukit/posix/src/semtimedwait.c index 58d6e24ed9..09028f4d08 100644 --- a/cpukit/posix/src/semtimedwait.c +++ b/cpukit/posix/src/semtimedwait.c @@ -60,7 +60,7 @@ int sem_timedwait( * TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST, or TOD_ABSOLUTE_TIMEOUT_IS_NOW, * then we should not wait. */ - status = _TOD_Absolute_timeout_to_ticks( abstime, &ticks ); + status = _TOD_Absolute_timeout_to_ticks( abstime, CLOCK_REALTIME, &ticks ); if ( status != TOD_ABSOLUTE_TIMEOUT_IS_IN_FUTURE ) do_wait = false; |