xref: /freebsd/contrib/llvm-project/libcxx/include/__system_error/errc.h (revision b64c5a0ace59af62eff52bfe110a521dc73c937b)
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef _LIBCPP___ERRC
11 #define _LIBCPP___ERRC
12 
13 /*
14     system_error synopsis
15 
16 namespace std
17 {
18 
19 enum class errc
20 {
21     address_family_not_supported,       // EAFNOSUPPORT
22     address_in_use,                     // EADDRINUSE
23     address_not_available,              // EADDRNOTAVAIL
24     already_connected,                  // EISCONN
25     argument_list_too_long,             // E2BIG
26     argument_out_of_domain,             // EDOM
27     bad_address,                        // EFAULT
28     bad_file_descriptor,                // EBADF
29     bad_message,                        // EBADMSG
30     broken_pipe,                        // EPIPE
31     connection_aborted,                 // ECONNABORTED
32     connection_already_in_progress,     // EALREADY
33     connection_refused,                 // ECONNREFUSED
34     connection_reset,                   // ECONNRESET
35     cross_device_link,                  // EXDEV
36     destination_address_required,       // EDESTADDRREQ
37     device_or_resource_busy,            // EBUSY
38     directory_not_empty,                // ENOTEMPTY
39     executable_format_error,            // ENOEXEC
40     file_exists,                        // EEXIST
41     file_too_large,                     // EFBIG
42     filename_too_long,                  // ENAMETOOLONG
43     function_not_supported,             // ENOSYS
44     host_unreachable,                   // EHOSTUNREACH
45     identifier_removed,                 // EIDRM
46     illegal_byte_sequence,              // EILSEQ
47     inappropriate_io_control_operation, // ENOTTY
48     integrity_check_failed,             // EINTEGRITY // FreeBSD customization
49     interrupted,                        // EINTR
50     invalid_argument,                   // EINVAL
51     invalid_seek,                       // ESPIPE
52     io_error,                           // EIO
53     is_a_directory,                     // EISDIR
54     message_size,                       // EMSGSIZE
55     network_down,                       // ENETDOWN
56     network_reset,                      // ENETRESET
57     network_unreachable,                // ENETUNREACH
58     no_buffer_space,                    // ENOBUFS
59     no_child_process,                   // ECHILD
60     no_link,                            // ENOLINK
61     no_lock_available,                  // ENOLCK
62     no_message_available,               // ENODATA         // deprecated
63     no_message,                         // ENOMSG
64     no_protocol_option,                 // ENOPROTOOPT
65     no_space_on_device,                 // ENOSPC
66     no_stream_resources,                // ENOSR           // deprecated
67     no_such_device_or_address,          // ENXIO
68     no_such_device,                     // ENODEV
69     no_such_file_or_directory,          // ENOENT
70     no_such_process,                    // ESRCH
71     not_a_directory,                    // ENOTDIR
72     not_a_socket,                       // ENOTSOCK
73     not_a_stream,                       // ENOSTR          // deprecated
74     not_connected,                      // ENOTCONN
75     not_enough_memory,                  // ENOMEM
76     not_supported,                      // ENOTSUP
77     operation_canceled,                 // ECANCELED
78     operation_in_progress,              // EINPROGRESS
79     operation_not_permitted,            // EPERM
80     operation_not_supported,            // EOPNOTSUPP
81     operation_would_block,              // EWOULDBLOCK
82     owner_dead,                         // EOWNERDEAD
83     permission_denied,                  // EACCES
84     protocol_error,                     // EPROTO
85     protocol_not_supported,             // EPROTONOSUPPORT
86     read_only_file_system,              // EROFS
87     resource_deadlock_would_occur,      // EDEADLK
88     resource_unavailable_try_again,     // EAGAIN
89     result_out_of_range,                // ERANGE
90     state_not_recoverable,              // ENOTRECOVERABLE
91     stream_timeout,                     // ETIME           // deprecated
92     text_file_busy,                     // ETXTBSY
93     timed_out,                          // ETIMEDOUT
94     too_many_files_open_in_system,      // ENFILE
95     too_many_files_open,                // EMFILE
96     too_many_links,                     // EMLINK
97     too_many_symbolic_link_levels,      // ELOOP
98     value_too_large,                    // EOVERFLOW
99     wrong_protocol_type                 // EPROTOTYPE
100 };
101 
102 */
103 
104 #include <__config>
105 #include <cerrno>
106 
107 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
108 #  pragma GCC system_header
109 #endif
110 
111 // The method of pushing and popping the diagnostics fails for GCC.  GCC does
112 // not recognize the pragma's used to generate deprecated diagnostics for
113 // macros. So GCC does not need the pushing and popping.
114 //
115 // TODO Remove this when the deprecated constants are removed.
116 //
117 // Note based on the post-review comments in
118 // https://github.com/llvm/llvm-project/pull/80542 libc++ no longer deprecates
119 // the macros. Since C libraries may start to deprecate these POSIX macros the
120 // deprecation warning avoidance is kept.
121 #if defined(_LIBCPP_COMPILER_CLANG_BASED)
122 #  define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH _LIBCPP_SUPPRESS_DEPRECATED_PUSH
123 #  define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP _LIBCPP_SUPPRESS_DEPRECATED_POP
124 #else
125 #  define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
126 #  define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
127 #endif
128 
129 _LIBCPP_BEGIN_NAMESPACE_STD
130 
131 // Some error codes are not present on all platforms, so we provide equivalents
132 // for them:
133 
134 // enum class errc
135 //
136 // LWG3869 deprecates the UNIX STREAMS macros and enum values.
137 // This makes the code clumbersome:
138 // - the enum value is deprecated and should show a diagnostic,
139 // - the macro is deprecated and should _not_ show a diagnostic in this
140 //   context, and
141 // - the macro is not always available.
142 // This leads to the odd pushing and popping of the deprecated
143 // diagnostic.
144 _LIBCPP_DECLARE_STRONG_ENUM(errc){
145     address_family_not_supported       = EAFNOSUPPORT,
146     address_in_use                     = EADDRINUSE,
147     address_not_available              = EADDRNOTAVAIL,
148     already_connected                  = EISCONN,
149     argument_list_too_long             = E2BIG,
150     argument_out_of_domain             = EDOM,
151     bad_address                        = EFAULT,
152     bad_file_descriptor                = EBADF,
153     bad_message                        = EBADMSG,
154     broken_pipe                        = EPIPE,
155     connection_aborted                 = ECONNABORTED,
156     connection_already_in_progress     = EALREADY,
157     connection_refused                 = ECONNREFUSED,
158     connection_reset                   = ECONNRESET,
159     cross_device_link                  = EXDEV,
160     destination_address_required       = EDESTADDRREQ,
161     device_or_resource_busy            = EBUSY,
162     directory_not_empty                = ENOTEMPTY,
163     executable_format_error            = ENOEXEC,
164     file_exists                        = EEXIST,
165     file_too_large                     = EFBIG,
166     filename_too_long                  = ENAMETOOLONG,
167     function_not_supported             = ENOSYS,
168     host_unreachable                   = EHOSTUNREACH,
169     identifier_removed                 = EIDRM,
170     illegal_byte_sequence              = EILSEQ,
171     inappropriate_io_control_operation = ENOTTY,
172 #ifdef EINTEGRITY
173     integrity_check_failed             = EINTEGRITY, // FreeBSD customization
174 #endif
175     interrupted                        = EINTR,
176     invalid_argument                   = EINVAL,
177     invalid_seek                       = ESPIPE,
178     io_error                           = EIO,
179     is_a_directory                     = EISDIR,
180     message_size                       = EMSGSIZE,
181     network_down                       = ENETDOWN,
182     network_reset                      = ENETRESET,
183     network_unreachable                = ENETUNREACH,
184     no_buffer_space                    = ENOBUFS,
185     no_child_process                   = ECHILD,
186     no_link                            = ENOLINK,
187     no_lock_available                  = ENOLCK,
188     // clang-format off
189     no_message_available _LIBCPP_DEPRECATED =
190     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
191 #ifdef ENODATA
192                                               ENODATA
193 #else
194                                               ENOMSG
195 #endif
196     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
197     ,
198     // clang-format on
199     no_message         = ENOMSG,
200     no_protocol_option = ENOPROTOOPT,
201     no_space_on_device = ENOSPC,
202     // clang-format off
203     no_stream_resources _LIBCPP_DEPRECATED =
204     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
205 #ifdef ENOSR
206                                               ENOSR
207 #else
208                                               ENOMEM
209 #endif
210     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
211     ,
212     // clang-format on
213     no_such_device_or_address = ENXIO,
214     no_such_device            = ENODEV,
215     no_such_file_or_directory = ENOENT,
216     no_such_process           = ESRCH,
217     not_a_directory           = ENOTDIR,
218     not_a_socket              = ENOTSOCK,
219     // clang-format off
220     not_a_stream _LIBCPP_DEPRECATED =
221     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
222 #ifdef ENOSTR
223                                       ENOSTR
224 #else
225                                       EINVAL
226 #endif
227     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
228     ,
229     // clang-format on
230     not_connected                  = ENOTCONN,
231     not_enough_memory              = ENOMEM,
232     not_supported                  = ENOTSUP,
233     operation_canceled             = ECANCELED,
234     operation_in_progress          = EINPROGRESS,
235     operation_not_permitted        = EPERM,
236     operation_not_supported        = EOPNOTSUPP,
237     operation_would_block          = EWOULDBLOCK,
238     owner_dead                     = EOWNERDEAD,
239     permission_denied              = EACCES,
240     protocol_error                 = EPROTO,
241     protocol_not_supported         = EPROTONOSUPPORT,
242     read_only_file_system          = EROFS,
243     resource_deadlock_would_occur  = EDEADLK,
244     resource_unavailable_try_again = EAGAIN,
245     result_out_of_range            = ERANGE,
246     state_not_recoverable          = ENOTRECOVERABLE,
247     // clang-format off
248     stream_timeout _LIBCPP_DEPRECATED =
249     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
250 #ifdef ETIME
251                                         ETIME
252 #else
253                                         ETIMEDOUT
254 #endif
255     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
256     ,
257     // clang-format on
258     text_file_busy                = ETXTBSY,
259     timed_out                     = ETIMEDOUT,
260     too_many_files_open_in_system = ENFILE,
261     too_many_files_open           = EMFILE,
262     too_many_links                = EMLINK,
263     too_many_symbolic_link_levels = ELOOP,
264     value_too_large               = EOVERFLOW,
265     wrong_protocol_type           = EPROTOTYPE};
266 _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
267 
268 _LIBCPP_END_NAMESPACE_STD
269 
270 #endif // _LIBCPP___ERRC
271