source: rtems/cpukit/posix/src/prwlockinit.c @ 047d67a

4.104.114.84.95
Last change on this file since 047d67a was 047d67a, checked in by Joel Sherrill <joel.sherrill@…>, on 11/15/06 at 14:08:49

2006-11-15 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/termios.c, posix/Makefile.am, posix/preinstall.am, posix/include/rtems/posix/config.h, posix/include/rtems/posix/time.h, sapi/src/posixapi.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/corerwlock.h, score/include/rtems/score/threadq.h, score/src/corerwlockobtainread.c, score/src/threadqenqueue.c, score/src/threadqtimeout.c: Adding POSIX barriers, POSIX spinlocks, and partial implementation of POSIX rwlocks.
  • posix/include/rtems/posix/barrier.h, posix/include/rtems/posix/rwlock.h, posix/include/rtems/posix/spinlock.h, posix/inline/rtems/posix/barrier.inl, posix/inline/rtems/posix/rwlock.inl, posix/inline/rtems/posix/spinlock.inl, posix/src/barrierattrdestroy.c, posix/src/barrierattrgetpshared.c, posix/src/barrierattrinit.c, posix/src/barrierattrsetpshared.c, posix/src/pbarrier.c, posix/src/pbarrierdestroy.c, posix/src/pbarrierinit.c, posix/src/pbarriertranslatereturncode.c, posix/src/pbarrierwait.c, posix/src/prwlock.c, posix/src/prwlockdestroy.c, posix/src/prwlockinit.c, posix/src/prwlockrdlock.c, posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, posix/src/prwlocktranslatereturncode.c, posix/src/prwlocktryrdlock.c, posix/src/prwlocktrywrlock.c, posix/src/prwlockunlock.c, posix/src/prwlockwrlock.c, posix/src/pspin.c, posix/src/pspindestroy.c, posix/src/pspininit.c, posix/src/pspinlock.c, posix/src/pspinlocktranslatereturncode.c, posix/src/pspintrylock.c, posix/src/pspinunlock.c, posix/src/rwlockattrdestroy.c, posix/src/rwlockattrgetpshared.c, posix/src/rwlockattrinit.c, posix/src/rwlockattrsetpshared.c: New files.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  POSIX RWLock Manager -- Destroy a RWLock 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 *  $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/rwlock.h>
23
24/*
25 *  pthread_rwlock_init
26 *
27 *  This directive creates a rwlock.  A rwlock id is returned.
28 *
29 *  Input parameters:
30 *    rwlock          - pointer to rwlock id
31 *    attr            - rwlock attributes
32 *
33 *  Output parameters:
34 *    rwlock     - rwlock id
35 *    0          - if successful
36 *    error code - if unsuccessful
37 */
38
39int pthread_rwlock_init(
40  pthread_rwlock_t           *rwlock,
41  const pthread_rwlockattr_t *attr
42)
43{
44  POSIX_RWLock_Control   *the_rwlock;
45  CORE_RWLock_Attributes  the_attributes;
46 
47
48  if ( !rwlock )
49    return EINVAL;
50
51  if ( !attr )
52    return EINVAL;
53
54  if ( !attr->is_initialized )
55    return EINVAL;
56
57  switch ( attr->process_shared ) {
58    case PTHREAD_PROCESS_PRIVATE:    /* only supported values */
59      break;
60    case PTHREAD_PROCESS_SHARED:
61    default:
62      return EINVAL;
63  }
64
65/*
66  the_attributes.discipline    = CORE_RWLOCK_AUTOMATIC_RELEASE;
67*/
68
69  _Thread_Disable_dispatch();             /* prevents deletion */
70
71  the_rwlock = _POSIX_RWLock_Allocate();
72
73  if ( !the_rwlock ) {
74    _Thread_Enable_dispatch();
75    return EAGAIN;
76  }
77
78  _CORE_RWLock_Initialize( &the_rwlock->RWLock, &the_attributes );
79
80  _Objects_Open(
81    &_POSIX_RWLock_Information,
82    &the_rwlock->Object,
83    0
84  );
85
86  *rwlock = the_rwlock->Object.id;
87
88  _Thread_Enable_dispatch();
89  return 0;
90}
Note: See TracBrowser for help on using the repository browser.