[c18e0ba] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
[35b8f48a] | 4 | * @brief Status Mapping Arrays |
---|
[c18e0ba] | 5 | * @ingroup ClassicStatus |
---|
| 6 | */ |
---|
| 7 | |
---|
[35b8f48a] | 8 | /* COPYRIGHT (c) 1989-2013. |
---|
[95008c6] | 9 | * On-Line Applications Research Corporation (OAR). |
---|
| 10 | * |
---|
| 11 | * The license and distribution terms for this file may be |
---|
| 12 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 13 | * http://www.rtems.org/license/LICENSE. |
---|
[95008c6] | 14 | */ |
---|
| 15 | |
---|
[faa2f8c4] | 16 | #include <rtems/rtems/statusimpl.h> |
---|
[35b8f48a] | 17 | #include <errno.h> |
---|
[95008c6] | 18 | |
---|
| 19 | const rtems_status_code _Status_Object_name_errors_to_status[] = { |
---|
[702e820] | 20 | /** This maps OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL to RTEMS_SUCCESSFUL. */ |
---|
[95008c6] | 21 | RTEMS_SUCCESSFUL, |
---|
| 22 | /** This maps OBJECTS_INVALID_NAME to RTEMS_INVALID_NAME. */ |
---|
| 23 | RTEMS_INVALID_NAME, |
---|
[702e820] | 24 | /** This maps OBJECTS_INVALID_ADDRESS to RTEMS_INVALID_ADDRESS. */ |
---|
[95008c6] | 25 | RTEMS_INVALID_ADDRESS, |
---|
[702e820] | 26 | /** This maps OBJECTS_INVALID_ID to RTEMS_INVALID_ID. */ |
---|
[95008c6] | 27 | RTEMS_INVALID_ID, |
---|
| 28 | /** This maps OBJECTS_INVALID_NODE to RTEMS_INVALID_NODE. */ |
---|
| 29 | RTEMS_INVALID_NODE |
---|
| 30 | }; |
---|
[35b8f48a] | 31 | |
---|
| 32 | static const int status_code_to_errno [RTEMS_STATUS_CODES_LAST + 1] = { |
---|
| 33 | [RTEMS_SUCCESSFUL] = 0, |
---|
| 34 | [RTEMS_TASK_EXITTED] = EIO, |
---|
| 35 | [RTEMS_MP_NOT_CONFIGURED] = EIO, |
---|
| 36 | [RTEMS_INVALID_NAME] = EINVAL, |
---|
| 37 | [RTEMS_INVALID_ID] = EIO, |
---|
| 38 | [RTEMS_TOO_MANY] = EIO, |
---|
| 39 | [RTEMS_TIMEOUT] = ETIMEDOUT, |
---|
| 40 | [RTEMS_OBJECT_WAS_DELETED] = EIO, |
---|
| 41 | [RTEMS_INVALID_SIZE] = EIO, |
---|
| 42 | [RTEMS_INVALID_ADDRESS] = EIO, |
---|
| 43 | [RTEMS_INVALID_NUMBER] = EBADF, |
---|
| 44 | [RTEMS_NOT_DEFINED] = EIO, |
---|
| 45 | [RTEMS_RESOURCE_IN_USE] = EBUSY, |
---|
| 46 | [RTEMS_UNSATISFIED] = ENODEV, |
---|
| 47 | [RTEMS_INCORRECT_STATE] = EIO, |
---|
| 48 | [RTEMS_ALREADY_SUSPENDED] = EIO, |
---|
| 49 | [RTEMS_ILLEGAL_ON_SELF] = EIO, |
---|
| 50 | [RTEMS_ILLEGAL_ON_REMOTE_OBJECT] = EIO, |
---|
| 51 | [RTEMS_CALLED_FROM_ISR] = EIO, |
---|
| 52 | [RTEMS_INVALID_PRIORITY] = EIO, |
---|
| 53 | [RTEMS_INVALID_CLOCK] = EINVAL, |
---|
| 54 | [RTEMS_INVALID_NODE] = EINVAL, |
---|
| 55 | [RTEMS_NOT_CONFIGURED] = ENOSYS, |
---|
| 56 | [RTEMS_NOT_OWNER_OF_RESOURCE] = EPERM, |
---|
| 57 | [RTEMS_NOT_IMPLEMENTED] = ENOSYS, |
---|
| 58 | [RTEMS_INTERNAL_ERROR] = EIO, |
---|
| 59 | [RTEMS_NO_MEMORY] = ENOMEM, |
---|
| 60 | [RTEMS_IO_ERROR] = EIO, |
---|
| 61 | [RTEMS_PROXY_BLOCKING] = EIO |
---|
| 62 | }; |
---|
| 63 | |
---|
| 64 | int rtems_status_code_to_errno(rtems_status_code sc) |
---|
| 65 | { |
---|
| 66 | if (sc == RTEMS_SUCCESSFUL) { |
---|
| 67 | return 0; |
---|
| 68 | } else { |
---|
| 69 | int eno = EINVAL; |
---|
| 70 | |
---|
| 71 | if ((unsigned) sc <= RTEMS_STATUS_CODES_LAST) { |
---|
| 72 | eno = status_code_to_errno [sc]; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | errno = eno; |
---|
| 76 | |
---|
| 77 | return -1; |
---|
| 78 | } |
---|
| 79 | } |
---|