summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pspinlock.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cpukit/posix/src/pspinlock.c50
1 files changed, 15 insertions, 35 deletions
diff --git a/cpukit/posix/src/pspinlock.c b/cpukit/posix/src/pspinlock.c
index d13ffe6b5c..502177c50e 100644
--- a/cpukit/posix/src/pspinlock.c
+++ b/cpukit/posix/src/pspinlock.c
@@ -18,46 +18,26 @@
#include "config.h"
#endif
-#include <pthread.h>
-#include <errno.h>
-
-#include <rtems/system.h>
#include <rtems/posix/spinlockimpl.h>
-/**
- * This directive allows a thread to wait at a spinlock.
- *
- * @param[in] spinlock is spinlock id
- *
- * @return This method returns 0 if there was not an
- * error. Otherwise, a status code is returned indicating the
- * source of the error.
- */
-int pthread_spin_lock(
- pthread_spinlock_t *spinlock
-)
+#include <errno.h>
+
+int pthread_spin_lock( pthread_spinlock_t *spinlock )
{
- POSIX_Spinlock_Control *the_spinlock = NULL;
- Objects_Locations location;
- CORE_spinlock_Status status;
+ POSIX_Spinlock_Control *the_spinlock;
+ ISR_lock_Context lock_context;
+ CORE_spinlock_Status status;
- if ( !spinlock )
+ the_spinlock = _POSIX_Spinlock_Get( spinlock, &lock_context );
+ if ( the_spinlock == NULL ) {
return EINVAL;
-
- the_spinlock = _POSIX_Spinlock_Get( spinlock, &location );
- switch ( location ) {
-
- case OBJECTS_LOCAL:
- status = _CORE_spinlock_Wait( &the_spinlock->Spinlock, true, 0 );
- _Objects_Put( &the_spinlock->Object );
- return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
-
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
-#endif
- case OBJECTS_ERROR:
- break;
}
- return EINVAL;
+ status = _CORE_spinlock_Seize(
+ &the_spinlock->Spinlock,
+ true,
+ 0,
+ &lock_context
+ );
+ return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
}