source: rtems/cpukit/posix/src/prwlocktrywrlock.c @ 7d53ba7f

4.104.114.95
Last change on this file since 7d53ba7f was 7d53ba7f, checked in by Ralf Corsepius <ralf.corsepius@…>, on 07/29/08 at 08:51:16

Use C-style comments.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  POSIX RWLock Manager -- Attempt to Obtain a Write Lock on a RWLock Instance
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/rwlock.h>
23
24/*
25 *  pthread_rwlock_trywrlock
26 *
27 *  This directive attempts to obtain a Write only lock on an rwlock instance.
28 *
29 *  Input parameters:
30 *    rwlock          - pointer to rwlock id
31 *
32 *  Output parameters:
33 *    0          - if successful
34 *    error code - if unsuccessful
35 */
36
37int pthread_rwlock_trywrlock(
38  pthread_rwlock_t  *rwlock
39)
40{
41  POSIX_RWLock_Control  *the_rwlock;
42  Objects_Locations      location;
43 
44  if ( !rwlock )
45    return EINVAL;
46
47  the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
48  switch ( location ) {
49
50    case OBJECTS_LOCAL:
51
52      _CORE_RWLock_Obtain_for_writing(
53        &the_rwlock->RWLock,
54        *rwlock,
55        FALSE,                 /* we are not willing to wait */
56        0,
57        NULL
58      );
59
60      _Thread_Enable_dispatch();
61      return _POSIX_RWLock_Translate_core_RWLock_return_code(
62        (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
63      );
64
65#if defined(RTEMS_MULTIPROCESSING)
66    case OBJECTS_REMOTE:
67#endif
68    case OBJECTS_ERROR:
69      break;
70  }
71
72  return EINVAL;
73}
Note: See TracBrowser for help on using the repository browser.