source: rtems/cpukit/rtems/src/status.c @ 702e820

Last change on this file since 702e820 was 702e820, checked in by Martin Erik Werner <martinerikwerner.aac@…>, on Nov 20, 2017 at 5:53:22 PM

Fix comments for object lookup error to RTEMS status map

Based on correlation with the enum for object lookup errors in
cpukit/score/include/rtems/score/objectimpl.h:

typedef enum {

OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL,
OBJECTS_INVALID_NAME,
OBJECTS_INVALID_ADDRESS,
OBJECTS_INVALID_ID,
OBJECTS_INVALID_NODE

} Objects_Name_or_id_lookup_errors;

update the comments regarding the object lookup error to status map to
match.

Signed-off-by: Martin Erik Werner <martin.werner@…>

  • Property mode set to 100644
File size: 2.4 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
19const rtems_status_code _Status_Object_name_errors_to_status[] = {
20  /** This maps OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL to RTEMS_SUCCESSFUL. */
21  RTEMS_SUCCESSFUL,
22  /** This maps OBJECTS_INVALID_NAME to RTEMS_INVALID_NAME. */
23  RTEMS_INVALID_NAME,
24  /** This maps OBJECTS_INVALID_ADDRESS to RTEMS_INVALID_ADDRESS. */
25  RTEMS_INVALID_ADDRESS,
26  /** This maps OBJECTS_INVALID_ID to RTEMS_INVALID_ID. */
27  RTEMS_INVALID_ID,
28  /** This maps OBJECTS_INVALID_NODE to RTEMS_INVALID_NODE. */
29  RTEMS_INVALID_NODE
30};
31
32static 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
64int 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}
Note: See TracBrowser for help on using the repository browser.