OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [posix/] [src/] [semaphorewaitsupp.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
2
 *  semaphorewaitsupp.c,v 1.5 2002/01/04 18:28:24 joel Exp
3
 */
4
 
5
#if HAVE_CONFIG_H
6
#include "config.h"
7
#endif
8
 
9
#include <stdarg.h>
10
 
11
#include <errno.h>
12
#include <fcntl.h>
13
#include <pthread.h>
14
#include <semaphore.h>
15
#include <limits.h>
16
 
17
#include <rtems/system.h>
18
#include <rtems/score/object.h>
19
#include <rtems/posix/semaphore.h>
20
#include <rtems/posix/time.h>
21
#include <rtems/seterr.h>
22
 
23
/*PAGE
24
 *
25
 *  _POSIX_Semaphore_Wait_support
26
 */
27
 
28
int _POSIX_Semaphore_Wait_support(
29
  sem_t              *sem,
30
  boolean             blocking,
31
  Watchdog_Interval   timeout
32
)
33
{
34
  register POSIX_Semaphore_Control *the_semaphore;
35
  Objects_Locations                 location;
36
 
37
  the_semaphore = _POSIX_Semaphore_Get( sem, &location );
38
  switch ( location ) {
39
    case OBJECTS_ERROR:
40
      rtems_set_errno_and_return_minus_one( EINVAL );
41
    case OBJECTS_REMOTE:
42
      _Thread_Dispatch();
43
      rtems_set_errno_and_return_minus_one( EINVAL );
44
    case OBJECTS_LOCAL:
45
      _CORE_semaphore_Seize(
46
        &the_semaphore->Semaphore,
47
        the_semaphore->Object.id,
48
        blocking,
49
        timeout
50
      );
51
      _Thread_Enable_dispatch();
52
      switch ( _Thread_Executing->Wait.return_code ) {
53
        case CORE_SEMAPHORE_STATUS_SUCCESSFUL:
54
          break;
55
        case CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT:
56
          rtems_set_errno_and_return_minus_one( EAGAIN );
57
        case CORE_SEMAPHORE_WAS_DELETED:
58
          rtems_set_errno_and_return_minus_one( EAGAIN );
59
        case CORE_SEMAPHORE_TIMEOUT:
60
          rtems_set_errno_and_return_minus_one( ETIMEDOUT );
61
          break;
62
        case CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED:
63
          /*
64
           *  This error can not occur since we set the maximum
65
           *  count to the largest value the count can hold.
66
           */
67
          break;
68
      }
69
  }
70
  return 0;
71
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.