summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-03-07 16:01:57 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-03-14 09:06:27 +0100
commit77e6eba7146ba2e2074b719eec01cc7c40bbe98b (patch)
treeec87c51ccd9c53cb65067a2a06a75d29b32387f3 /cpukit/posix
parentpc386: Fix linker usage issues with -r and function sections (diff)
downloadrtems-77e6eba7146ba2e2074b719eec01cc7c40bbe98b.tar.bz2
score: Add and use _Objects_Get_local()
This simplifies the handling with local-only objects. Update #2555.
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/include/rtems/posix/timerimpl.h4
-rw-r--r--cpukit/posix/src/timerdelete.c36
-rw-r--r--cpukit/posix/src/timergetoverrun.c26
-rw-r--r--cpukit/posix/src/timergettime.c37
-rw-r--r--cpukit/posix/src/timersettime.c78
5 files changed, 73 insertions, 108 deletions
diff --git a/cpukit/posix/include/rtems/posix/timerimpl.h b/cpukit/posix/include/rtems/posix/timerimpl.h
index 2eefd7063c..bf25629529 100644
--- a/cpukit/posix/include/rtems/posix/timerimpl.h
+++ b/cpukit/posix/include/rtems/posix/timerimpl.h
@@ -94,14 +94,12 @@ void _POSIX_Timer_TSR( Watchdog_Control *the_watchdog );
*/
RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get (
timer_t id,
- Objects_Locations *location,
ISR_lock_Context *lock_context
)
{
- return (POSIX_Timer_Control *) _Objects_Get_isr_disable(
+ return (POSIX_Timer_Control *) _Objects_Get_local(
&_POSIX_Timer_Information,
(Objects_Id) id,
- location,
lock_context
);
}
diff --git a/cpukit/posix/src/timerdelete.c b/cpukit/posix/src/timerdelete.c
index c39de8e168..5301a708c9 100644
--- a/cpukit/posix/src/timerdelete.c
+++ b/cpukit/posix/src/timerdelete.c
@@ -44,33 +44,25 @@ int timer_delete(
* because rtems_timer_delete stops the timer before deleting it.
*/
POSIX_Timer_Control *ptimer;
- Objects_Locations location;
ISR_lock_Context lock_context;
- Per_CPU_Control *cpu;
_Objects_Allocator_lock();
- ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
- switch ( location ) {
- case OBJECTS_LOCAL:
- _Objects_Close( &_POSIX_Timer_Information, &ptimer->Object );
- cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
- ptimer->state = POSIX_TIMER_STATE_FREE;
- _Watchdog_Remove(
- &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
- &ptimer->Timer
- );
- _POSIX_Timer_Release( cpu, &lock_context );
- _POSIX_Timer_Free( ptimer );
- _Objects_Allocator_unlock();
+ ptimer = _POSIX_Timer_Get( timerid, &lock_context );
+ if ( ptimer != NULL ) {
+ Per_CPU_Control *cpu;
- return 0;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
-#endif
- case OBJECTS_ERROR:
- break;
+ _Objects_Close( &_POSIX_Timer_Information, &ptimer->Object );
+ cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
+ ptimer->state = POSIX_TIMER_STATE_FREE;
+ _Watchdog_Remove(
+ &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
+ &ptimer->Timer
+ );
+ _POSIX_Timer_Release( cpu, &lock_context );
+ _POSIX_Timer_Free( ptimer );
+ _Objects_Allocator_unlock();
+ return 0;
}
_Objects_Allocator_unlock();
diff --git a/cpukit/posix/src/timergetoverrun.c b/cpukit/posix/src/timergetoverrun.c
index 0a28fa7b5f..0a7b9fafa6 100644
--- a/cpukit/posix/src/timergetoverrun.c
+++ b/cpukit/posix/src/timergetoverrun.c
@@ -30,27 +30,19 @@ int timer_getoverrun(
timer_t timerid
)
{
- int overrun;
POSIX_Timer_Control *ptimer;
- Objects_Locations location;
ISR_lock_Context lock_context;
- Per_CPU_Control *cpu;
- ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
- switch ( location ) {
+ ptimer = _POSIX_Timer_Get( timerid, &lock_context );
+ if ( ptimer != NULL ) {
+ Per_CPU_Control *cpu;
+ int overrun;
- case OBJECTS_LOCAL:
- cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
- overrun = ptimer->overrun;
- ptimer->overrun = 0;
- _POSIX_Timer_Release( cpu, &lock_context );
- return overrun;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
-#endif
- case OBJECTS_ERROR:
- break;
+ cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
+ overrun = ptimer->overrun;
+ ptimer->overrun = 0;
+ _POSIX_Timer_Release( cpu, &lock_context );
+ return overrun;
}
rtems_set_errno_and_return_minus_one( EINVAL );
diff --git a/cpukit/posix/src/timergettime.c b/cpukit/posix/src/timergettime.c
index 7f0015bf5e..66708e947b 100644
--- a/cpukit/posix/src/timergettime.c
+++ b/cpukit/posix/src/timergettime.c
@@ -41,40 +41,31 @@ int timer_gettime(
)
{
POSIX_Timer_Control *ptimer;
- Objects_Locations location;
ISR_lock_Context lock_context;
- Per_CPU_Control *cpu;
uint64_t now;
uint32_t remaining;
if ( !value )
rtems_set_errno_and_return_minus_one( EINVAL );
- ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
- switch ( location ) {
+ ptimer = _POSIX_Timer_Get( timerid, &lock_context );
+ if ( ptimer != NULL ) {
+ Per_CPU_Control *cpu;
- case OBJECTS_LOCAL:
+ cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
+ now = cpu->Watchdog.ticks;
- cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
- now = cpu->Watchdog.ticks;
+ if ( now < ptimer->Timer.expire ) {
+ remaining = (uint32_t) ( ptimer->Timer.expire - now );
+ } else {
+ remaining = 0;
+ }
- if ( now < ptimer->Timer.expire ) {
- remaining = (uint32_t) ( ptimer->Timer.expire - now );
- } else {
- remaining = 0;
- }
+ _Timespec_From_ticks( remaining, &value->it_value );
+ value->it_interval = ptimer->timer_data.it_interval;
- _Timespec_From_ticks( remaining, &value->it_value );
- value->it_interval = ptimer->timer_data.it_interval;
-
- _POSIX_Timer_Release( cpu, &lock_context );
- return 0;
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
-#endif
- case OBJECTS_ERROR:
- break;
+ _POSIX_Timer_Release( cpu, &lock_context );
+ return 0;
}
rtems_set_errno_and_return_minus_one( EINVAL );
diff --git a/cpukit/posix/src/timersettime.c b/cpukit/posix/src/timersettime.c
index ac5c258eda..51678ca5cb 100644
--- a/cpukit/posix/src/timersettime.c
+++ b/cpukit/posix/src/timersettime.c
@@ -107,9 +107,7 @@ int timer_settime(
)
{
POSIX_Timer_Control *ptimer;
- Objects_Locations location;
ISR_lock_Context lock_context;
- Per_CPU_Control *cpu;
uint32_t initial_period;
struct itimerspec normalize;
@@ -148,53 +146,47 @@ int timer_settime(
* or start it again
*/
- ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
- switch ( location ) {
-
- case OBJECTS_LOCAL:
- cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
-
- /* Stop the timer */
- _Watchdog_Remove(
- &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
- &ptimer->Timer
- );
-
- /* First, it verifies if the timer must be stopped */
- if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) {
- /* The old data of the timer are returned */
- if ( ovalue )
- *ovalue = ptimer->timer_data;
- /* The new data are set */
- ptimer->timer_data = normalize;
- /* Indicates that the timer is created and stopped */
- ptimer->state = POSIX_TIMER_STATE_CREATE_STOP;
- /* Returns with success */
- _POSIX_Timer_Release( cpu, &lock_context );
- return 0;
- }
-
- /* Convert from seconds and nanoseconds to ticks */
- ptimer->ticks = _Timespec_To_ticks( &value->it_interval );
- initial_period = _Timespec_To_ticks( &normalize.it_value );
-
- _POSIX_Timer_Insert( ptimer, cpu, initial_period );
-
- /*
- * The timer has been started and is running. So we return the
- * old ones in "ovalue"
- */
+ ptimer = _POSIX_Timer_Get( timerid, &lock_context );
+ if ( ptimer != NULL ) {
+ Per_CPU_Control *cpu;
+
+ cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
+
+ /* Stop the timer */
+ _Watchdog_Remove(
+ &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
+ &ptimer->Timer
+ );
+
+ /* First, it verifies if the timer must be stopped */
+ if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) {
+ /* The old data of the timer are returned */
if ( ovalue )
*ovalue = ptimer->timer_data;
+ /* The new data are set */
ptimer->timer_data = normalize;
+ /* Indicates that the timer is created and stopped */
+ ptimer->state = POSIX_TIMER_STATE_CREATE_STOP;
+ /* Returns with success */
_POSIX_Timer_Release( cpu, &lock_context );
return 0;
+ }
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
-#endif
- case OBJECTS_ERROR:
- break;
+ /* Convert from seconds and nanoseconds to ticks */
+ ptimer->ticks = _Timespec_To_ticks( &value->it_interval );
+ initial_period = _Timespec_To_ticks( &normalize.it_value );
+
+ _POSIX_Timer_Insert( ptimer, cpu, initial_period );
+
+ /*
+ * The timer has been started and is running. So we return the
+ * old ones in "ovalue"
+ */
+ if ( ovalue )
+ *ovalue = ptimer->timer_data;
+ ptimer->timer_data = normalize;
+ _POSIX_Timer_Release( cpu, &lock_context );
+ return 0;
}
rtems_set_errno_and_return_minus_one( EINVAL );