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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [semaphorewaitsupp.c] - Blame information for rev 580

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  $Id: semaphorewaitsupp.c,v 1.2 2001-09-27 11:59:17 chris Exp $
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
 
24
int _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
}

powered by: WebSVN 2.1.0

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