1 | /* |
---|
2 | * POSIX Message Queue Error Translation |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2007. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | */ |
---|
11 | |
---|
12 | #if HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <pthread.h> |
---|
17 | #include <errno.h> |
---|
18 | |
---|
19 | #include <rtems/system.h> |
---|
20 | #include <rtems/score/coremsg.h> |
---|
21 | #include <rtems/posix/mqueue.h> |
---|
22 | |
---|
23 | /* |
---|
24 | * _POSIX_Message_queue_Translate_core_message_queue_return_code |
---|
25 | * |
---|
26 | * Input parameters: |
---|
27 | * the_message_queue_status - message_queue status code to translate |
---|
28 | * |
---|
29 | * Output parameters: |
---|
30 | * status code - translated POSIX status code |
---|
31 | * |
---|
32 | */ |
---|
33 | |
---|
34 | static |
---|
35 | int _POSIX_Message_queue_Return_codes[CORE_MESSAGE_QUEUE_STATUS_LAST + 1] = { |
---|
36 | 0, /* CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL */ |
---|
37 | EMSGSIZE, /* CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE */ |
---|
38 | EAGAIN, /* CORE_MESSAGE_QUEUE_STATUS_TOO_MANY */ |
---|
39 | ENOMEM, /* CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED */ |
---|
40 | EAGAIN, /* CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT */ |
---|
41 | EBADF, /* CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED */ |
---|
42 | ETIMEDOUT, /* CORE_MESSAGE_QUEUE_STATUS_TIMEOUT */ |
---|
43 | ENOSYS /* CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT */ |
---|
44 | }; |
---|
45 | |
---|
46 | |
---|
47 | int _POSIX_Message_queue_Translate_core_message_queue_return_code( |
---|
48 | uint32_t the_message_queue_status |
---|
49 | ) |
---|
50 | { |
---|
51 | /* |
---|
52 | * Internal consistency check for bad status from SuperCore |
---|
53 | */ |
---|
54 | #if defined(RTEMS_DEBUG) |
---|
55 | if ( the_message_queue_status > CORE_MESSAGE_QUEUE_STATUS_LAST ) |
---|
56 | return EINVAL; |
---|
57 | #endif |
---|
58 | return _POSIX_Message_queue_Return_codes[the_message_queue_status]; |
---|
59 | } |
---|