source: rtems/cpukit/rtems/src/statustoerrno.c @ 21275b58

5
Last change on this file since 21275b58 was 7d7c50de, checked in by Sebastian Huber <sebastian.huber@…>, on 05/25/18 at 12:09:46

rtems: Move _Status_Object_name_errors_to_status

Move _Status_Object_name_errors_to_status to a separate file to avoid a
dependency on errno. Dependencies to errno are hard to be removed by
the linker garbage collection.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Status Mapping Arrays
5 *  @ingroup ClassicStatus
6 */
7
8/*  COPYRIGHT (c) 1989-2013.
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
13 *  http://www.rtems.org/license/LICENSE.
14 */
15
16#include <rtems/rtems/statusimpl.h>
17#include <errno.h>
18
19static const int status_code_to_errno [RTEMS_STATUS_CODES_LAST + 1] = {
20  [RTEMS_SUCCESSFUL]               = 0,
21  [RTEMS_TASK_EXITTED]             = EIO,
22  [RTEMS_MP_NOT_CONFIGURED]        = EIO,
23  [RTEMS_INVALID_NAME]             = EINVAL,
24  [RTEMS_INVALID_ID]               = EIO,
25  [RTEMS_TOO_MANY]                 = EIO,
26  [RTEMS_TIMEOUT]                  = ETIMEDOUT,
27  [RTEMS_OBJECT_WAS_DELETED]       = EIO,
28  [RTEMS_INVALID_SIZE]             = EIO,
29  [RTEMS_INVALID_ADDRESS]          = EIO,
30  [RTEMS_INVALID_NUMBER]           = EBADF,
31  [RTEMS_NOT_DEFINED]              = EIO,
32  [RTEMS_RESOURCE_IN_USE]          = EBUSY,
33  [RTEMS_UNSATISFIED]              = ENODEV,
34  [RTEMS_INCORRECT_STATE]          = EIO,
35  [RTEMS_ALREADY_SUSPENDED]        = EIO,
36  [RTEMS_ILLEGAL_ON_SELF]          = EIO,
37  [RTEMS_ILLEGAL_ON_REMOTE_OBJECT] = EIO,
38  [RTEMS_CALLED_FROM_ISR]          = EIO,
39  [RTEMS_INVALID_PRIORITY]         = EIO,
40  [RTEMS_INVALID_CLOCK]            = EINVAL,
41  [RTEMS_INVALID_NODE]             = EINVAL,
42  [RTEMS_NOT_CONFIGURED]           = ENOSYS,
43  [RTEMS_NOT_OWNER_OF_RESOURCE]    = EPERM,
44  [RTEMS_NOT_IMPLEMENTED]          = ENOSYS,
45  [RTEMS_INTERNAL_ERROR]           = EIO,
46  [RTEMS_NO_MEMORY]                = ENOMEM,
47  [RTEMS_IO_ERROR]                 = EIO,
48  [RTEMS_PROXY_BLOCKING]           = EIO
49};
50
51int rtems_status_code_to_errno(rtems_status_code sc)
52{
53  if (sc == RTEMS_SUCCESSFUL) {
54    return 0;
55  } else {
56    int eno = EINVAL;
57
58    if ((unsigned) sc <= RTEMS_STATUS_CODES_LAST) {
59      eno = status_code_to_errno [sc];
60    }
61
62    errno = eno;
63
64    return -1;
65  }
66}
Note: See TracBrowser for help on using the repository browser.