source: rtems/cpukit/posix/src/semaphorewaitsupp.c @ cfa5aab

4.115
Last change on this file since cfa5aab was cfa5aab, checked in by Sebastian Huber <sebastian.huber@…>, on 05/02/15 at 12:02:20

score: Delete _CORE_semaphore_Seize()

Rename _CORE_semaphore_Seize_isr_disable() to _CORE_semaphore_Seize().

  • Property mode set to 100644
File size: 1.6 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.org/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/posix/semaphoreimpl.h>
31#include <rtems/posix/time.h>
32#include <rtems/seterr.h>
33
34int _POSIX_Semaphore_Wait_support(
35  sem_t             *sem,
36  bool               blocking,
37  Watchdog_Interval  timeout
38)
39{
40  POSIX_Semaphore_Control *the_semaphore;
41  Objects_Locations        location;
42  Thread_Control          *executing;
43  ISR_lock_Context         lock_context;
44
45  the_semaphore = _POSIX_Semaphore_Get_interrupt_disable(
46    sem,
47    &location,
48    &lock_context
49  );
50  switch ( location ) {
51
52    case OBJECTS_LOCAL:
53      executing = _Thread_Executing;
54      _CORE_semaphore_Seize(
55        &the_semaphore->Semaphore,
56        executing,
57        the_semaphore->Object.id,
58        blocking,
59        timeout,
60        &lock_context
61      );
62
63      if ( !executing->Wait.return_code )
64        return 0;
65
66      rtems_set_errno_and_return_minus_one(
67        _POSIX_Semaphore_Translate_core_semaphore_return_code(
68          executing->Wait.return_code
69        )
70      );
71
72#if defined(RTEMS_MULTIPROCESSING)
73    case OBJECTS_REMOTE:
74#endif
75    case OBJECTS_ERROR:
76      break;
77  }
78
79  rtems_set_errno_and_return_minus_one( EINVAL );
80}
Note: See TracBrowser for help on using the repository browser.