RTEMS
status.h
1 /*
2  * Copyright (c) 2016 embedded brains GmbH. All rights reserved.
3  *
4  * embedded brains GmbH
5  * Dornierstr. 4
6  * 82178 Puchheim
7  * Germany
8  * <rtems@embedded-brains.de>
9  *
10  * The license and distribution terms for this file may be
11  * found in the file LICENSE in this distribution or at
12  * http://www.rtems.org/license/LICENSE.
13  */
14 
15 #ifndef _RTEMS_SCORE_STATUS_H
16 #define _RTEMS_SCORE_STATUS_H
17 
18 #include <rtems/score/basedefs.h>
19 
20 #include <errno.h>
21 #include <pthread.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26 
32 typedef enum {
33  STATUS_CLASSIC_INCORRECT_STATE = 14,
34  STATUS_CLASSIC_INTERNAL_ERROR = 13,
35  STATUS_CLASSIC_INVALID_NUMBER = 10,
36  STATUS_CLASSIC_INVALID_PRIORITY = 19,
37  STATUS_CLASSIC_INVALID_SIZE = 8,
38  STATUS_CLASSIC_NO_MEMORY = 26,
39  STATUS_CLASSIC_NOT_DEFINED = 11,
40  STATUS_CLASSIC_NOT_OWNER_OF_RESOURCE = 23,
41  STATUS_CLASSIC_OBJECT_WAS_DELETED = 7,
42  STATUS_CLASSIC_PROXY_BLOCKING = 29,
43  STATUS_CLASSIC_RESOURCE_IN_USE = 12,
44  STATUS_CLASSIC_SUCCESSFUL = 0,
45  STATUS_CLASSIC_TIMEOUT = 6,
46  STATUS_CLASSIC_TOO_MANY = 5,
47  STATUS_CLASSIC_UNSATISFIED = 13
48 } Status_Classic;
49 
55 #define STATUS_BUILD( classic_status, posix_status ) \
56  ( ( ( posix_status ) * 256 ) | ( classic_status ) )
57 
61 #define STATUS_GET_CLASSIC( status ) \
62  ( ( status ) & 0xff )
63 
69 #define STATUS_GET_POSIX( status ) \
70  ( ( status ) / 256 )
71 
75 typedef enum {
76  STATUS_BARRIER_AUTOMATICALLY_RELEASED =
77  STATUS_BUILD( STATUS_CLASSIC_SUCCESSFUL, PTHREAD_BARRIER_SERIAL_THREAD ),
78  STATUS_DEADLOCK =
79  STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EDEADLK ),
80  STATUS_FLUSHED =
81  STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EAGAIN ),
82  STATUS_INCORRECT_STATE =
83  STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EINVAL ),
84  STATUS_INTERRUPTED =
85  STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EINTR ),
86  STATUS_INVALID_NUMBER =
87  STATUS_BUILD( STATUS_CLASSIC_INVALID_NUMBER, EINVAL ),
88  STATUS_INVALID_PRIORITY =
89  STATUS_BUILD( STATUS_CLASSIC_INVALID_PRIORITY, EINVAL ),
90  STATUS_MAXIMUM_COUNT_EXCEEDED =
91  STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EOVERFLOW ),
92  STATUS_MESSAGE_INVALID_SIZE =
93  STATUS_BUILD( STATUS_CLASSIC_INVALID_SIZE, EMSGSIZE ),
94  STATUS_MESSAGE_QUEUE_INVALID_NUMBER =
95  STATUS_BUILD( STATUS_CLASSIC_INVALID_NUMBER, ENOSPC ),
96  STATUS_MESSAGE_QUEUE_INVALID_SIZE =
97  STATUS_BUILD( STATUS_CLASSIC_INVALID_SIZE, ENOSPC ),
98  STATUS_MESSAGE_QUEUE_NO_MEMORY =
99  STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, ENOSPC ),
100  STATUS_MESSAGE_QUEUE_WAIT_IN_ISR =
101  STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EAGAIN ),
102  STATUS_MESSAGE_QUEUE_WAS_DELETED =
103  STATUS_BUILD( STATUS_CLASSIC_OBJECT_WAS_DELETED, EBADF ),
104  STATUS_MINUS_ONE =
105  -1,
106  STATUS_MUTEX_CEILING_VIOLATED =
107  STATUS_BUILD( STATUS_CLASSIC_INVALID_PRIORITY, EINVAL ),
108  STATUS_NESTING_NOT_ALLOWED =
109  STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EDEADLK ),
110  STATUS_NO_MEMORY =
111  STATUS_BUILD( STATUS_CLASSIC_NO_MEMORY, EINVAL ),
112  STATUS_NOT_DEFINED =
113  STATUS_BUILD( STATUS_CLASSIC_NOT_DEFINED, EINVAL ),
114  STATUS_NOT_OWNER =
115  STATUS_BUILD( STATUS_CLASSIC_NOT_OWNER_OF_RESOURCE, EPERM ),
116  STATUS_OBJECT_WAS_DELETED =
117  STATUS_BUILD( STATUS_CLASSIC_OBJECT_WAS_DELETED, EINVAL ),
118  STATUS_PROXY_BLOCKING =
119  STATUS_BUILD( STATUS_CLASSIC_PROXY_BLOCKING, EINVAL ),
120  STATUS_RESOURCE_IN_USE =
121  STATUS_BUILD( STATUS_CLASSIC_RESOURCE_IN_USE, EBUSY ),
122  STATUS_RESULT_TOO_LARGE =
123  STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, ERANGE ),
124  STATUS_SUCCESSFUL =
125  STATUS_BUILD( STATUS_CLASSIC_SUCCESSFUL, 0 ),
126  STATUS_TIMEOUT =
127  STATUS_BUILD( STATUS_CLASSIC_TIMEOUT, ETIMEDOUT ),
128  STATUS_TOO_MANY =
129  STATUS_BUILD( STATUS_CLASSIC_TOO_MANY, EAGAIN ),
130  STATUS_UNAVAILABLE =
131  STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EBUSY ),
132  STATUS_UNSATISFIED =
133  STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EAGAIN )
134 } Status_Control;
135 
136 #ifdef __cplusplus
137 }
138 #endif /* __cplusplus */
139 
140 #endif /* _RTEMS_SCORE_STATUS_H */
This header file provides basic definitions used by the API and the implementation.