summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src
diff options
context:
space:
mode:
authorJoel Sherrill <joel@rtems.org>2019-11-12 09:33:41 -0600
committerJoel Sherrill <joel@rtems.org>2019-12-11 15:22:33 -0600
commit08bd7d36cee1b041d54ee9dbace86a1b810938af (patch)
tree18de7bd20167d7430c82810d375534c56dfedb91 /cpukit/posix/src
parentpipe: Use condition variables (diff)
downloadrtems-08bd7d36cee1b041d54ee9dbace86a1b810938af.tar.bz2
Add TOD Hooks to allow BSP to take action when TOD is set
Two use cases were envisioned for this. 1) a BSP or application which desires to update a real-time clock when the RTEMS TOD is set. 2) a paravirtualized BSP can use this to propagate setting the time in an RTEMS application to the hosting environment. This enables the entire set of applications in the virtualized environments to have a single consistent TOD.
Diffstat (limited to 'cpukit/posix/src')
-rw-r--r--cpukit/posix/src/clocksettime.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/cpukit/posix/src/clocksettime.c b/cpukit/posix/src/clocksettime.c
index a0fdd9109f..bfae46feee 100644
--- a/cpukit/posix/src/clocksettime.c
+++ b/cpukit/posix/src/clocksettime.c
@@ -32,6 +32,8 @@ int clock_settime(
const struct timespec *tp
)
{
+ bool retval;
+
if ( !tp )
rtems_set_errno_and_return_minus_one( EINVAL );
@@ -43,19 +45,25 @@ int clock_settime(
_TOD_Lock();
_TOD_Acquire( &lock_context );
- _TOD_Set( tp, &lock_context );
+ retval = _TOD_Set( tp, &lock_context );
_TOD_Unlock();
+ if ( retval == false ) {
+ rtems_set_errno_and_return_minus_one( EPERM );
+ }
}
#ifdef _POSIX_CPUTIME
- else if ( clock_id == CLOCK_PROCESS_CPUTIME_ID )
+ else if ( clock_id == CLOCK_PROCESS_CPUTIME_ID ) {
rtems_set_errno_and_return_minus_one( ENOSYS );
+ }
#endif
#ifdef _POSIX_THREAD_CPUTIME
- else if ( clock_id == CLOCK_THREAD_CPUTIME_ID )
+ else if ( clock_id == CLOCK_THREAD_CPUTIME_ID ) {
rtems_set_errno_and_return_minus_one( ENOSYS );
+ }
#endif
- else
+ else {
rtems_set_errno_and_return_minus_one( EINVAL );
+ }
return 0;
}