4.104.114.84.95
Last change
on this file since 811fae1 was
799c767,
checked in by Joel Sherrill <joel.sherrill@…>, on 11/02/99 at 18:00:15
|
Split the POSIX semaphore manager into multiple files.
|
-
Property mode set to
100644
|
File size:
1.4 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 | |
---|
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 | int code; |
---|
33 | |
---|
34 | the_semaphore = _POSIX_Semaphore_Get( sem, &location ); |
---|
35 | switch ( location ) { |
---|
36 | case OBJECTS_ERROR: |
---|
37 | set_errno_and_return_minus_one( EINVAL ); |
---|
38 | case OBJECTS_REMOTE: |
---|
39 | _Thread_Dispatch(); |
---|
40 | return POSIX_MP_NOT_IMPLEMENTED(); |
---|
41 | set_errno_and_return_minus_one( EINVAL ); |
---|
42 | case OBJECTS_LOCAL: |
---|
43 | _CORE_semaphore_Seize( |
---|
44 | &the_semaphore->Semaphore, |
---|
45 | the_semaphore->Object.id, |
---|
46 | blocking, |
---|
47 | timeout |
---|
48 | ); |
---|
49 | _Thread_Enable_dispatch(); |
---|
50 | code = _Thread_Executing->Wait.return_code; |
---|
51 | switch (_Thread_Executing->Wait.return_code) { |
---|
52 | case 1: |
---|
53 | errno = EAGAIN; |
---|
54 | code = -1; |
---|
55 | break; |
---|
56 | case 3: |
---|
57 | errno = ETIMEDOUT; |
---|
58 | code = -1; |
---|
59 | break; |
---|
60 | } |
---|
61 | |
---|
62 | /*return _Thread_Executing->Wait.return_code;*/ |
---|
63 | return code; |
---|
64 | } |
---|
65 | return POSIX_BOTTOM_REACHED(); |
---|
66 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.