summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2006-10-30 22:21:23 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2006-10-30 22:21:23 +0000
commit0c2ec7f52c496e436f09d44dcb880bf4ea16ba86 (patch)
treea9b300a256bb640e1abfdc6dbbb6eac0a49c6a96 /cpukit/posix
parent2006-10-30 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-0c2ec7f52c496e436f09d44dcb880bf4ea16ba86.tar.bz2
2006-10-30 Joel Sherrill <joel@OARcorp.com>
PR 841/rtems * itron/inline/rtems/itron/semaphore.inl, itron/src/twai_sem.c, posix/include/rtems/posix/semaphore.h, posix/inline/rtems/posix/semaphore.inl, posix/src/semaphorewaitsupp.c, posix/src/semtimedwait.c, posix/src/semwait.c, rtems/src/semobtain.c, rtems/src/semtranslatereturncode.c, score/include/rtems/score/coresem.h, score/src/coresemseize.c: Make sem_timedwait more conformant to Open Group specification.
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/include/rtems/posix/semaphore.h6
-rw-r--r--cpukit/posix/inline/rtems/posix/semaphore.inl2
-rw-r--r--cpukit/posix/src/semaphorewaitsupp.c13
-rw-r--r--cpukit/posix/src/semtimedwait.c49
-rw-r--r--cpukit/posix/src/semwait.c6
5 files changed, 43 insertions, 33 deletions
diff --git a/cpukit/posix/include/rtems/posix/semaphore.h b/cpukit/posix/include/rtems/posix/semaphore.h
index 5fd0f5f171..26e0a6b804 100644
--- a/cpukit/posix/include/rtems/posix/semaphore.h
+++ b/cpukit/posix/include/rtems/posix/semaphore.h
@@ -153,9 +153,9 @@ void _POSIX_Semaphore_Delete(
*/
int _POSIX_Semaphore_Wait_support(
- sem_t *sem,
- boolean blocking,
- Watchdog_Interval timeout
+ sem_t *sem,
+ Core_semaphore_Blocking_option blocking,
+ Watchdog_Interval timeout
);
/*
diff --git a/cpukit/posix/inline/rtems/posix/semaphore.inl b/cpukit/posix/inline/rtems/posix/semaphore.inl
index 6369d6f09c..5c96d75e02 100644
--- a/cpukit/posix/inline/rtems/posix/semaphore.inl
+++ b/cpukit/posix/inline/rtems/posix/semaphore.inl
@@ -64,7 +64,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Semaphore_Namespace_remove (
*/
RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *_POSIX_Semaphore_Get (
- sem_t *id,
+ sem_t *id,
Objects_Locations *location
)
{
diff --git a/cpukit/posix/src/semaphorewaitsupp.c b/cpukit/posix/src/semaphorewaitsupp.c
index 7c76ff87bd..1c5f815b25 100644
--- a/cpukit/posix/src/semaphorewaitsupp.c
+++ b/cpukit/posix/src/semaphorewaitsupp.c
@@ -26,13 +26,13 @@
*/
int _POSIX_Semaphore_Wait_support(
- sem_t *sem,
- boolean blocking,
- Watchdog_Interval timeout
+ sem_t *sem,
+ Core_semaphore_Blocking_option blocking,
+ Watchdog_Interval timeout
)
{
- register POSIX_Semaphore_Control *the_semaphore;
- Objects_Locations location;
+ POSIX_Semaphore_Control *the_semaphore;
+ Objects_Locations location;
the_semaphore = _POSIX_Semaphore_Get( sem, &location );
switch ( location ) {
@@ -65,6 +65,9 @@ int _POSIX_Semaphore_Wait_support(
* count to the largest value the count can hold.
*/
break;
+ case CORE_SEMAPHORE_BAD_TIMEOUT_VALUE:
+ rtems_set_errno_and_return_minus_one( EINVAL );
+ break;
}
}
return 0;
diff --git a/cpukit/posix/src/semtimedwait.c b/cpukit/posix/src/semtimedwait.c
index 6acb704f7c..b0cb78deca 100644
--- a/cpukit/posix/src/semtimedwait.c
+++ b/cpukit/posix/src/semtimedwait.c
@@ -35,34 +35,37 @@ int sem_timedwait(
/*
* The abstime is a walltime. We turn it into an interval.
*/
- Watchdog_Interval ticks;
- struct timespec current_time;
- struct timespec difference;
+ Watchdog_Interval ticks = 0;
+ struct timespec current_time;
+ struct timespec difference;
+ Core_semaphore_Blocking_option blocking = CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT;
/*
* Error check the absolute time to timeout
*/
+#if 0
if ( /* abstime->tv_sec < 0 || */ abstime->tv_nsec ) /* tv_sec is unsigned */
- return EINVAL;
-
+ blocking = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE;
+ else
+#endif
if ( abstime->tv_nsec >= TOD_NANOSECONDS_PER_SECOND )
- return EINVAL;
-
- (void) clock_gettime( CLOCK_REALTIME, &current_time );
-
- /*
- * Make sure the abstime is in the future
- */
- if ( abstime->tv_sec < current_time.tv_sec )
- return EINVAL;
- if ( (abstime->tv_sec == current_time.tv_sec) &&
- (abstime->tv_nsec <= current_time.tv_nsec) )
- return EINVAL;
-
- _POSIX_Timespec_subtract( &current_time, abstime, &difference );
+ blocking = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE;
+ else {
+ (void) clock_gettime( CLOCK_REALTIME, &current_time );
+ /*
+ * Make sure the abstime is in the future
+ */
+ if ( abstime->tv_sec < current_time.tv_sec )
+ blocking = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE;
+ else if ( (abstime->tv_sec == current_time.tv_sec) &&
+ (abstime->tv_nsec <= current_time.tv_nsec) )
+ blocking = CORE_SEMAPHORE_BAD_TIMEOUT_VALUE;
+ else {
+ _POSIX_Timespec_subtract( &current_time, abstime, &difference );
+ ticks = _POSIX_Timespec_to_interval( &difference );
+ blocking = CORE_SEMAPHORE_BLOCK_WITH_TIMEOUT;
+ }
+ }
- ticks = _POSIX_Timespec_to_interval( &difference );
-
- return _POSIX_Semaphore_Wait_support( sem, TRUE, ticks );
+ return _POSIX_Semaphore_Wait_support( sem, blocking, ticks );
}
-
diff --git a/cpukit/posix/src/semwait.c b/cpukit/posix/src/semwait.c
index 9ef787c727..b43a1e47b4 100644
--- a/cpukit/posix/src/semwait.c
+++ b/cpukit/posix/src/semwait.c
@@ -31,5 +31,9 @@ int sem_wait(
sem_t *sem
)
{
- return _POSIX_Semaphore_Wait_support( sem, TRUE, THREAD_QUEUE_WAIT_FOREVER );
+ return _POSIX_Semaphore_Wait_support(
+ sem,
+ CORE_SEMAPHORE_BLOCK_FOREVER,
+ THREAD_QUEUE_WAIT_FOREVER
+ );
}