source: rtems/cpukit/posix/src/semaphorewaitsupp.c @ 2c3af4c5

4.104.114.84.95
Last change on this file since 2c3af4c5 was 0ca4fc8, checked in by Jennifer Averett <Jennifer.Averett@…>, on 11/22/99 at 16:09:55

+ Corrected error processing code.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  $Id$
3 */
4
5#include <stdarg.h>
6
7#include <errno.h>
8#include <fcntl.h>
9#include <pthread.h>
10#include <semaphore.h>
11#include <limits.h>
12
13#include <rtems/system.h>
14#include <rtems/score/object.h>
15#include <rtems/posix/semaphore.h>
16#include <rtems/posix/time.h>
17#include <rtems/posix/seterr.h>
18
19/*PAGE
20 *
21 *  _POSIX_Semaphore_Wait_support
22 */
23
24int _POSIX_Semaphore_Wait_support(
25  sem_t              *sem,
26  boolean             blocking,
27  Watchdog_Interval   timeout
28)
29{
30  register POSIX_Semaphore_Control *the_semaphore;
31  Objects_Locations                 location;
32 
33  the_semaphore = _POSIX_Semaphore_Get( sem, &location );
34  switch ( location ) {
35    case OBJECTS_ERROR:
36      set_errno_and_return_minus_one( EINVAL );
37    case OBJECTS_REMOTE:
38      _Thread_Dispatch();
39      set_errno_and_return_minus_one( EINVAL );
40    case OBJECTS_LOCAL:
41      _CORE_semaphore_Seize(
42        &the_semaphore->Semaphore,
43        the_semaphore->Object.id,
44        blocking,
45        timeout
46      );
47      _Thread_Enable_dispatch();
48      switch ( _Thread_Executing->Wait.return_code ) {
49        case CORE_SEMAPHORE_STATUS_SUCCESSFUL:
50          break;
51        case CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT:
52          set_errno_and_return_minus_one( EAGAIN );
53        case CORE_SEMAPHORE_WAS_DELETED:
54          set_errno_and_return_minus_one( EAGAIN );
55        case CORE_SEMAPHORE_TIMEOUT:
56          set_errno_and_return_minus_one( ETIMEDOUT );
57          break;
58        case CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED:
59          /*
60           *  This error can not occur since we set the maximum
61           *  count to the largest value the count can hold.
62           */
63          break;
64      }
65  }
66  return 0;
67}
Note: See TracBrowser for help on using the repository browser.