]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/status.h
Update to version 3.2.0
[FreeBSD/FreeBSD.git] / include / status.h
1 /*
2  * *****************************************************************************
3  *
4  * SPDX-License-Identifier: BSD-2-Clause
5  *
6  * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * * Redistributions of source code must retain the above copyright notice, this
12  *   list of conditions and the following disclaimer.
13  *
14  * * Redistributions in binary form must reproduce the above copyright notice,
15  *   this list of conditions and the following disclaimer in the documentation
16  *   and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * *****************************************************************************
31  *
32  * All bc status codes.
33  *
34  */
35
36 #ifndef BC_STATUS_H
37 #define BC_STATUS_H
38
39 #include <stdint.h>
40
41 #ifndef BC_ENABLED
42 #define BC_ENABLED (1)
43 #endif // BC_ENABLED
44
45 #ifndef DC_ENABLED
46 #define DC_ENABLED (1)
47 #endif // DC_ENABLED
48
49 #include <bcl.h>
50
51 typedef enum BcStatus {
52
53         BC_STATUS_SUCCESS = 0,
54         BC_STATUS_ERROR_MATH,
55         BC_STATUS_ERROR_PARSE,
56         BC_STATUS_ERROR_EXEC,
57         BC_STATUS_ERROR_FATAL,
58         BC_STATUS_EOF,
59         BC_STATUS_QUIT,
60
61 } BcStatus;
62
63 typedef enum BcErr {
64
65         BC_ERR_MATH_NEGATIVE,
66         BC_ERR_MATH_NON_INTEGER,
67         BC_ERR_MATH_OVERFLOW,
68         BC_ERR_MATH_DIVIDE_BY_ZERO,
69
70         BC_ERR_FATAL_ALLOC_ERR,
71         BC_ERR_FATAL_IO_ERR,
72         BC_ERR_FATAL_FILE_ERR,
73         BC_ERR_FATAL_BIN_FILE,
74         BC_ERR_FATAL_PATH_DIR,
75         BC_ERR_FATAL_OPTION,
76         BC_ERR_FATAL_OPTION_NO_ARG,
77         BC_ERR_FATAL_OPTION_ARG,
78
79         BC_ERR_EXEC_IBASE,
80         BC_ERR_EXEC_OBASE,
81         BC_ERR_EXEC_SCALE,
82         BC_ERR_EXEC_READ_EXPR,
83         BC_ERR_EXEC_REC_READ,
84         BC_ERR_EXEC_TYPE,
85
86         BC_ERR_EXEC_STACK,
87
88         BC_ERR_EXEC_PARAMS,
89         BC_ERR_EXEC_UNDEF_FUNC,
90         BC_ERR_EXEC_VOID_VAL,
91
92         BC_ERR_PARSE_EOF,
93         BC_ERR_PARSE_CHAR,
94         BC_ERR_PARSE_STRING,
95         BC_ERR_PARSE_COMMENT,
96         BC_ERR_PARSE_TOKEN,
97 #if BC_ENABLED
98         BC_ERR_PARSE_EXPR,
99         BC_ERR_PARSE_EMPTY_EXPR,
100         BC_ERR_PARSE_PRINT,
101         BC_ERR_PARSE_FUNC,
102         BC_ERR_PARSE_ASSIGN,
103         BC_ERR_PARSE_NO_AUTO,
104         BC_ERR_PARSE_DUP_LOCAL,
105         BC_ERR_PARSE_BLOCK,
106         BC_ERR_PARSE_RET_VOID,
107         BC_ERR_PARSE_REF_VAR,
108
109         BC_ERR_POSIX_NAME_LEN,
110         BC_ERR_POSIX_COMMENT,
111         BC_ERR_POSIX_KW,
112         BC_ERR_POSIX_DOT,
113         BC_ERR_POSIX_RET,
114         BC_ERR_POSIX_BOOL,
115         BC_ERR_POSIX_REL_POS,
116         BC_ERR_POSIX_MULTIREL,
117         BC_ERR_POSIX_FOR,
118         BC_ERR_POSIX_EXP_NUM,
119         BC_ERR_POSIX_REF,
120         BC_ERR_POSIX_VOID,
121         BC_ERR_POSIX_BRACE,
122 #endif // BC_ENABLED
123
124         BC_ERR_NELEMS,
125
126 #if BC_ENABLED
127         BC_ERR_POSIX_START = BC_ERR_POSIX_NAME_LEN,
128         BC_ERR_POSIX_END = BC_ERR_POSIX_BRACE,
129 #endif // BC_ENABLED
130
131 } BcErr;
132
133 #define BC_ERR_IDX_MATH (0)
134 #define BC_ERR_IDX_PARSE (1)
135 #define BC_ERR_IDX_EXEC (2)
136 #define BC_ERR_IDX_FATAL (3)
137 #define BC_ERR_IDX_NELEMS (4)
138
139 #if BC_ENABLED
140 #define BC_ERR_IDX_WARN (BC_ERR_IDX_NELEMS)
141 #endif // BC_ENABLED
142
143 #define BC_UNUSED(e) ((void) (e))
144
145 #ifndef BC_LIKELY
146 #define BC_LIKELY(e) (e)
147 #endif // BC_LIKELY
148
149 #ifndef BC_UNLIKELY
150 #define BC_UNLIKELY(e) (e)
151 #endif // BC_UNLIKELY
152
153 #define BC_ERR(e) BC_UNLIKELY(e)
154 #define BC_NO_ERR(s) BC_LIKELY(s)
155
156 #ifndef BC_DEBUG_CODE
157 #define BC_DEBUG_CODE (0)
158 #endif // BC_DEBUG_CODE
159
160 #if __STDC_VERSION__ >= 201100L
161 #include <stdnoreturn.h>
162 #define BC_NORETURN _Noreturn
163 #else // __STDC_VERSION__
164 #define BC_NORETURN
165 #define BC_MUST_RETURN
166 #endif // __STDC_VERSION__
167
168 #if defined(__clang__) || defined(__GNUC__)
169 #define BC_FALLTHROUGH __attribute__((fallthrough));
170 #else // defined(__clang__) || defined(__GNUC__)
171 #define BC_FALLTHROUGH
172 #endif //defined(__clang__) || defined(__GNUC__)
173
174 // Workarounds for AIX's POSIX incompatibility.
175 #ifndef SIZE_MAX
176 #define SIZE_MAX __SIZE_MAX__
177 #endif // SIZE_MAX
178 #ifndef UINTMAX_C
179 #define UINTMAX_C __UINTMAX_C
180 #endif // UINTMAX_C
181 #ifndef UINT32_C
182 #define UINT32_C __UINT32_C
183 #endif // UINT32_C
184 #ifndef UINT_FAST32_MAX
185 #define UINT_FAST32_MAX __UINT_FAST32_MAX__
186 #endif // UINT_FAST32_MAX
187 #ifndef UINT16_MAX
188 #define UINT16_MAX __UINT16_MAX__
189 #endif // UINT16_MAX
190 #ifndef SIG_ATOMIC_MAX
191 #define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__
192 #endif // SIG_ATOMIC_MAX
193
194 #endif // BC_STATUS_H