source: rtems/cpukit/posix/src/semaphorewaitsupp.c @ 5cb175bb

4.115
Last change on this file since 5cb175bb was 5cb175bb, checked in by Joel Sherrill <joel.sherrill@…>, on 01/10/13 at 19:22:31

cpukit/posix: Doxygen group is POSIXAPI

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief POSIX Semaphore Wait Support
5 * @ingroup POSIXSemaphorePrivate
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2012.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <stdarg.h>
22
23#include <errno.h>
24#include <fcntl.h>
25#include <pthread.h>
26#include <semaphore.h>
27#include <limits.h>
28
29#include <rtems/system.h>
30#include <rtems/score/object.h>
31#include <rtems/posix/semaphore.h>
32#include <rtems/posix/time.h>
33#include <rtems/seterr.h>
34
35int _POSIX_Semaphore_Wait_support(
36  sem_t             *sem,
37  bool               blocking,
38  Watchdog_Interval  timeout
39)
40{
41  POSIX_Semaphore_Control *the_semaphore;
42  Objects_Locations        location;
43
44  the_semaphore = _POSIX_Semaphore_Get( sem, &location );
45  switch ( location ) {
46
47    case OBJECTS_LOCAL:
48      _CORE_semaphore_Seize(
49        &the_semaphore->Semaphore,
50        the_semaphore->Object.id,
51        blocking,
52        timeout
53      );
54      _Thread_Enable_dispatch();
55
56      if ( !_Thread_Executing->Wait.return_code )
57        return 0;
58
59      rtems_set_errno_and_return_minus_one(
60        _POSIX_Semaphore_Translate_core_semaphore_return_code(
61          _Thread_Executing->Wait.return_code
62        )
63      );
64
65#if defined(RTEMS_MULTIPROCESSING)
66    case OBJECTS_REMOTE:
67#endif
68    case OBJECTS_ERROR:
69      break;
70  }
71
72  rtems_set_errno_and_return_minus_one( EINVAL );
73}
Note: See TracBrowser for help on using the repository browser.