source: rtems/cpukit/posix/src/pspininit.c @ a0e6c73

4.115
Last change on this file since a0e6c73 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  POSIX Spinlock Manager -- Initialize a Spinlock Instance
3 *
4 *  COPYRIGHT (c) 1989-2006.
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
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <pthread.h>
17#include <errno.h>
18
19#include <rtems/system.h>
20#include <rtems/posix/spinlock.h>
21
22/*
23 *  pthread_spinlock_init
24 *
25 *  This directive creates a spinlock.  A spinlock id is returned.
26 *
27 *  Input parameters:
28 *    spinlock         - pointer to spinlock id
29 *    pshared          - is this spinlock shared between processes
30 *
31 *  Output parameters:
32 *    spinlock     - spinlock id
33 *    0           - if successful
34 *    error code  - if unsuccessful
35 */
36
37int pthread_spin_init(
38  pthread_spinlock_t  *spinlock,
39  int                  pshared
40)
41{
42  POSIX_Spinlock_Control   *the_spinlock;
43  CORE_spinlock_Attributes  attributes;
44
45
46  if ( !spinlock )
47    return EINVAL;
48
49  switch ( pshared ) {
50    case PTHREAD_PROCESS_PRIVATE:    /* only supported values */
51      break;
52    case PTHREAD_PROCESS_SHARED:
53    default:
54      return EINVAL;
55  }
56
57  _Thread_Disable_dispatch();             /* prevents deletion */
58
59  the_spinlock = _POSIX_Spinlock_Allocate();
60
61  if ( !the_spinlock ) {
62    _Thread_Enable_dispatch();
63    return EAGAIN;
64  }
65
66  _CORE_spinlock_Initialize_attributes( &attributes );
67
68  _CORE_spinlock_Initialize( &the_spinlock->Spinlock, &attributes );
69
70  _Objects_Open_u32( &_POSIX_Spinlock_Information, &the_spinlock->Object, 0 );
71
72  *spinlock = the_spinlock->Object.id;
73
74  _Thread_Enable_dispatch();
75  return 0;
76}
Note: See TracBrowser for help on using the repository browser.