source: rtems/cpukit/posix/src/pspinlock.c @ 8f6b7b51

4.104.115
Last change on this file since 8f6b7b51 was b1dbfd7, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/03/09 at 10:10:57

Eliminate TRUE/FALSE.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  POSIX Spinlock Manager -- Wait at a Spinlock
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <pthread.h>
19#include <errno.h>
20
21#include <rtems/system.h>
22#include <rtems/posix/spinlock.h>
23
24/*
25 *  pthread_spin_lock
26 *
27 *  This directive allows a thread to wait at a spinlock.
28 *
29 *  Input parameters:
30 *    spinlock    - spinlock id
31 *
32 *  Output parameters:
33 *    0          - if successful
34 *    error code - if unsuccessful
35 */
36
37int pthread_spin_lock(
38  pthread_spinlock_t *spinlock
39)
40{
41  POSIX_Spinlock_Control  *the_spinlock = NULL;
42  Objects_Locations        location;
43  CORE_spinlock_Status     status;
44
45  if ( !spinlock )
46    return EINVAL;
47
48  the_spinlock = _POSIX_Spinlock_Get( spinlock, &location );
49  switch ( location ) {
50
51    case OBJECTS_LOCAL:
52      status = _CORE_spinlock_Wait( &the_spinlock->Spinlock, true, 0 );
53      _Thread_Enable_dispatch();
54      return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
55
56#if defined(RTEMS_MULTIPROCESSING)
57    case OBJECTS_REMOTE:
58#endif
59    case OBJECTS_ERROR:
60      break;
61  }
62
63  return EINVAL;
64}
Note: See TracBrowser for help on using the repository browser.