1 | /* |
---|
2 | * POSIX Message Queue Error Translation |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-1999. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.com/license/LICENSE. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #if HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <pthread.h> |
---|
20 | #include <limits.h> |
---|
21 | #include <errno.h> |
---|
22 | #include <fcntl.h> |
---|
23 | #include <mqueue.h> |
---|
24 | |
---|
25 | #include <rtems/system.h> |
---|
26 | #include <rtems/score/watchdog.h> |
---|
27 | #include <rtems/seterr.h> |
---|
28 | #include <rtems/posix/mqueue.h> |
---|
29 | #include <rtems/posix/time.h> |
---|
30 | #include <rtems/score/interr.h> |
---|
31 | |
---|
32 | |
---|
33 | /*PAGE |
---|
34 | * |
---|
35 | * _POSIX_Message_queue_Translate_core_message_queue_return_code |
---|
36 | * |
---|
37 | * Input parameters: |
---|
38 | * the_message_queue_status - message_queue status code to translate |
---|
39 | * |
---|
40 | * Output parameters: |
---|
41 | * rtems status code - translated POSIX status code |
---|
42 | * |
---|
43 | */ |
---|
44 | |
---|
45 | int _POSIX_Message_queue_Translate_core_message_queue_return_code( |
---|
46 | uint32_t the_message_queue_status |
---|
47 | ) |
---|
48 | { |
---|
49 | switch ( the_message_queue_status ) { |
---|
50 | case CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL: |
---|
51 | return 0; |
---|
52 | |
---|
53 | /* |
---|
54 | * Bad message size |
---|
55 | */ |
---|
56 | case CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE: |
---|
57 | return EMSGSIZE; |
---|
58 | |
---|
59 | /* |
---|
60 | * Queue is full of pending messages. |
---|
61 | */ |
---|
62 | case CORE_MESSAGE_QUEUE_STATUS_TOO_MANY: |
---|
63 | return EAGAIN; |
---|
64 | |
---|
65 | /* |
---|
66 | * Out of message buffers to queue pending message |
---|
67 | */ |
---|
68 | case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED: |
---|
69 | return ENOMEM; |
---|
70 | |
---|
71 | /* |
---|
72 | * No message available on receive poll |
---|
73 | */ |
---|
74 | case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT: |
---|
75 | return EAGAIN; |
---|
76 | |
---|
77 | /* |
---|
78 | * Queue was deleted while thread blocked on it. |
---|
79 | */ |
---|
80 | case CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED: |
---|
81 | return EBADF; |
---|
82 | |
---|
83 | /* |
---|
84 | * POSIX Real-Time Extensions add timeouts to send and receive. |
---|
85 | */ |
---|
86 | case CORE_MESSAGE_QUEUE_STATUS_TIMEOUT: |
---|
87 | return ETIMEDOUT; |
---|
88 | |
---|
89 | /* |
---|
90 | * RTEMS POSIX API implementation does not support multiprocessing. |
---|
91 | */ |
---|
92 | case THREAD_STATUS_PROXY_BLOCKING: |
---|
93 | return ENOSYS; |
---|
94 | } |
---|
95 | _Internal_error_Occurred( |
---|
96 | INTERNAL_ERROR_POSIX_API, |
---|
97 | TRUE, |
---|
98 | the_message_queue_status |
---|
99 | ); |
---|
100 | return POSIX_BOTTOM_REACHED(); |
---|
101 | } |
---|