source: rtems/cpukit/posix/src/prwlocktimedrdlock.c @ 860c34e

4.104.114.95
Last change on this file since 860c34e was 860c34e, checked in by Glenn Humphrey <glenn.humphrey@…>, on 11/30/07 at 20:34:13

2007-11-30 Glenn Humphrey <glenn.humphrey@…>

  • posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/semaphore.h, posix/src/cancel.c, posix/src/conddestroy.c, posix/src/condsignalsupp.c, posix/src/condwaitsupp.c, posix/src/keydelete.c, posix/src/keygetspecific.c, posix/src/keysetspecific.c, posix/src/mqueueclose.c, posix/src/mqueuegetattr.c, posix/src/mqueuenotify.c, posix/src/mqueuerecvsupp.c, posix/src/mqueuesendsupp.c, posix/src/mqueuesetattr.c, posix/src/mqueuetranslatereturncode.c, posix/src/mutexdestroy.c, posix/src/mutexgetprioceiling.c, posix/src/mutexinit.c, posix/src/mutexlocksupp.c, posix/src/mutexsetprioceiling.c, posix/src/mutexunlock.c, posix/src/pbarrierdestroy.c, posix/src/pbarriertranslatereturncode.c, posix/src/pbarrierwait.c, posix/src/prwlockdestroy.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/pspindestroy.c, posix/src/pspinlock.c, posix/src/pspinlocktranslatereturncode.c, posix/src/pspintrylock.c, posix/src/pspinunlock.c, posix/src/pthreaddetach.c, posix/src/pthreadequal.c, posix/src/pthreadgetschedparam.c, posix/src/pthreadjoin.c, posix/src/pthreadkill.c, posix/src/pthreadsetschedparam.c, posix/src/ptimer1.c, posix/src/semaphorewaitsupp.c, posix/src/semclose.c, posix/src/semdestroy.c, posix/src/semgetvalue.c, posix/src/sempost.c, posix/src/types.c, rtems/src/msgqtranslatereturncode.c, rtems/src/semobtain.c, rtems/src/timerfireafter.c, score/include/rtems/system.h, score/include/rtems/score/corebarrier.h, score/include/rtems/score/coremsg.h, score/include/rtems/score/coremutex.h, score/include/rtems/score/coresem.h: Restructed to move the OBJECTS_LOCAL case to the top of the switch statement and eliminate the fall-through return of POSIX_BOTTOM_REACHED. These changes produced simplier assembly code and allowed for complete test coverage. Also applied some consistency to the functions that translate the core status codes to POSIX status codes.
  • posix/src/mutextranslatereturncode.c, posix/src/semaphoretranslatereturncode.c: New files.
  • posix/src/mutexfromcorestatus.c: Removed.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  POSIX RWLock Manager -- Attempt to Obtain a Read 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#include <rtems/posix/time.h>
24
25/*
26 *  pthread_rwlock_timedrdlock
27 *
28 *  This directive attempts to obtain a read only lock on an rwlock instance.
29 *
30 *  Input parameters:
31 *    rwlock          - pointer to rwlock id
32 *
33 *  Output parameters:
34 *    0          - if successful
35 *    error code - if unsuccessful
36 */
37
38int pthread_rwlock_timedrdlock(
39  pthread_rwlock_t      *rwlock,
40  const struct timespec *abstime
41)
42{
43  POSIX_RWLock_Control  *the_rwlock;
44  Objects_Locations      location;
45  Watchdog_Interval      ticks;
46  int                    status;
47 
48  if ( !rwlock )
49    return EINVAL;
50
51  status = _POSIX_Absolute_timeout_to_ticks( abstime, &ticks );
52  if ( status )
53    return status;
54
55  the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
56  switch ( location ) {
57
58    case OBJECTS_LOCAL:
59
60      _CORE_RWLock_Obtain_for_reading(
61        &the_rwlock->RWLock,
62        *rwlock,
63        TRUE,                   // we are willing to wait up to ticks
64        ticks,
65        NULL
66      );
67
68      _Thread_Enable_dispatch();
69      return _POSIX_RWLock_Translate_core_RWLock_return_code(
70        (CORE_RWLock_Status) _Thread_Executing->Wait.return_code
71      );
72
73#if defined(RTEMS_MULTIPROCESSING)
74    case OBJECTS_REMOTE:
75#endif
76    case OBJECTS_ERROR:
77      break;
78  }
79
80  return EINVAL;
81}
Note: See TracBrowser for help on using the repository browser.