xref: /freebsd-src/contrib/llvm-project/libcxx/include/__system_error/errc.h (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
106c3fb27SDimitry Andric // -*- C++ -*-
206c3fb27SDimitry Andric //===----------------------------------------------------------------------===//
306c3fb27SDimitry Andric //
406c3fb27SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
506c3fb27SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
606c3fb27SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
706c3fb27SDimitry Andric //
806c3fb27SDimitry Andric //===----------------------------------------------------------------------===//
906c3fb27SDimitry Andric 
1006c3fb27SDimitry Andric #ifndef _LIBCPP___ERRC
1106c3fb27SDimitry Andric #define _LIBCPP___ERRC
1206c3fb27SDimitry Andric 
1306c3fb27SDimitry Andric /*
1406c3fb27SDimitry Andric     system_error synopsis
1506c3fb27SDimitry Andric 
1606c3fb27SDimitry Andric namespace std
1706c3fb27SDimitry Andric {
1806c3fb27SDimitry Andric 
1906c3fb27SDimitry Andric enum class errc
2006c3fb27SDimitry Andric {
2106c3fb27SDimitry Andric     address_family_not_supported,       // EAFNOSUPPORT
2206c3fb27SDimitry Andric     address_in_use,                     // EADDRINUSE
2306c3fb27SDimitry Andric     address_not_available,              // EADDRNOTAVAIL
2406c3fb27SDimitry Andric     already_connected,                  // EISCONN
2506c3fb27SDimitry Andric     argument_list_too_long,             // E2BIG
2606c3fb27SDimitry Andric     argument_out_of_domain,             // EDOM
2706c3fb27SDimitry Andric     bad_address,                        // EFAULT
2806c3fb27SDimitry Andric     bad_file_descriptor,                // EBADF
2906c3fb27SDimitry Andric     bad_message,                        // EBADMSG
3006c3fb27SDimitry Andric     broken_pipe,                        // EPIPE
3106c3fb27SDimitry Andric     connection_aborted,                 // ECONNABORTED
3206c3fb27SDimitry Andric     connection_already_in_progress,     // EALREADY
3306c3fb27SDimitry Andric     connection_refused,                 // ECONNREFUSED
3406c3fb27SDimitry Andric     connection_reset,                   // ECONNRESET
3506c3fb27SDimitry Andric     cross_device_link,                  // EXDEV
3606c3fb27SDimitry Andric     destination_address_required,       // EDESTADDRREQ
3706c3fb27SDimitry Andric     device_or_resource_busy,            // EBUSY
3806c3fb27SDimitry Andric     directory_not_empty,                // ENOTEMPTY
3906c3fb27SDimitry Andric     executable_format_error,            // ENOEXEC
4006c3fb27SDimitry Andric     file_exists,                        // EEXIST
4106c3fb27SDimitry Andric     file_too_large,                     // EFBIG
4206c3fb27SDimitry Andric     filename_too_long,                  // ENAMETOOLONG
4306c3fb27SDimitry Andric     function_not_supported,             // ENOSYS
4406c3fb27SDimitry Andric     host_unreachable,                   // EHOSTUNREACH
4506c3fb27SDimitry Andric     identifier_removed,                 // EIDRM
4606c3fb27SDimitry Andric     illegal_byte_sequence,              // EILSEQ
4706c3fb27SDimitry Andric     inappropriate_io_control_operation, // ENOTTY
4846c59ea9SDimitry Andric     integrity_check_failed,             // EINTEGRITY // FreeBSD customization
4906c3fb27SDimitry Andric     interrupted,                        // EINTR
5006c3fb27SDimitry Andric     invalid_argument,                   // EINVAL
5106c3fb27SDimitry Andric     invalid_seek,                       // ESPIPE
5206c3fb27SDimitry Andric     io_error,                           // EIO
5306c3fb27SDimitry Andric     is_a_directory,                     // EISDIR
5406c3fb27SDimitry Andric     message_size,                       // EMSGSIZE
5506c3fb27SDimitry Andric     network_down,                       // ENETDOWN
5606c3fb27SDimitry Andric     network_reset,                      // ENETRESET
5706c3fb27SDimitry Andric     network_unreachable,                // ENETUNREACH
5806c3fb27SDimitry Andric     no_buffer_space,                    // ENOBUFS
5906c3fb27SDimitry Andric     no_child_process,                   // ECHILD
6006c3fb27SDimitry Andric     no_link,                            // ENOLINK
6106c3fb27SDimitry Andric     no_lock_available,                  // ENOLCK
62*0fca6ea1SDimitry Andric     no_message_available,               // ENODATA         // deprecated
6306c3fb27SDimitry Andric     no_message,                         // ENOMSG
6406c3fb27SDimitry Andric     no_protocol_option,                 // ENOPROTOOPT
6506c3fb27SDimitry Andric     no_space_on_device,                 // ENOSPC
66*0fca6ea1SDimitry Andric     no_stream_resources,                // ENOSR           // deprecated
6706c3fb27SDimitry Andric     no_such_device_or_address,          // ENXIO
6806c3fb27SDimitry Andric     no_such_device,                     // ENODEV
6906c3fb27SDimitry Andric     no_such_file_or_directory,          // ENOENT
7006c3fb27SDimitry Andric     no_such_process,                    // ESRCH
7106c3fb27SDimitry Andric     not_a_directory,                    // ENOTDIR
7206c3fb27SDimitry Andric     not_a_socket,                       // ENOTSOCK
73*0fca6ea1SDimitry Andric     not_a_stream,                       // ENOSTR          // deprecated
7406c3fb27SDimitry Andric     not_connected,                      // ENOTCONN
7506c3fb27SDimitry Andric     not_enough_memory,                  // ENOMEM
7606c3fb27SDimitry Andric     not_supported,                      // ENOTSUP
7706c3fb27SDimitry Andric     operation_canceled,                 // ECANCELED
7806c3fb27SDimitry Andric     operation_in_progress,              // EINPROGRESS
7906c3fb27SDimitry Andric     operation_not_permitted,            // EPERM
8006c3fb27SDimitry Andric     operation_not_supported,            // EOPNOTSUPP
8106c3fb27SDimitry Andric     operation_would_block,              // EWOULDBLOCK
8206c3fb27SDimitry Andric     owner_dead,                         // EOWNERDEAD
8306c3fb27SDimitry Andric     permission_denied,                  // EACCES
8406c3fb27SDimitry Andric     protocol_error,                     // EPROTO
8506c3fb27SDimitry Andric     protocol_not_supported,             // EPROTONOSUPPORT
8606c3fb27SDimitry Andric     read_only_file_system,              // EROFS
8706c3fb27SDimitry Andric     resource_deadlock_would_occur,      // EDEADLK
8806c3fb27SDimitry Andric     resource_unavailable_try_again,     // EAGAIN
8906c3fb27SDimitry Andric     result_out_of_range,                // ERANGE
9006c3fb27SDimitry Andric     state_not_recoverable,              // ENOTRECOVERABLE
91*0fca6ea1SDimitry Andric     stream_timeout,                     // ETIME           // deprecated
9206c3fb27SDimitry Andric     text_file_busy,                     // ETXTBSY
9306c3fb27SDimitry Andric     timed_out,                          // ETIMEDOUT
9406c3fb27SDimitry Andric     too_many_files_open_in_system,      // ENFILE
9506c3fb27SDimitry Andric     too_many_files_open,                // EMFILE
9606c3fb27SDimitry Andric     too_many_links,                     // EMLINK
9706c3fb27SDimitry Andric     too_many_symbolic_link_levels,      // ELOOP
9806c3fb27SDimitry Andric     value_too_large,                    // EOVERFLOW
9906c3fb27SDimitry Andric     wrong_protocol_type                 // EPROTOTYPE
10006c3fb27SDimitry Andric };
10106c3fb27SDimitry Andric 
10206c3fb27SDimitry Andric */
10306c3fb27SDimitry Andric 
10406c3fb27SDimitry Andric #include <__config>
10506c3fb27SDimitry Andric #include <cerrno>
10606c3fb27SDimitry Andric 
10706c3fb27SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
10806c3fb27SDimitry Andric #  pragma GCC system_header
10906c3fb27SDimitry Andric #endif
11006c3fb27SDimitry Andric 
111*0fca6ea1SDimitry Andric // The method of pushing and popping the diagnostics fails for GCC.  GCC does
112*0fca6ea1SDimitry Andric // not recognize the pragma's used to generate deprecated diagnostics for
113*0fca6ea1SDimitry Andric // macros. So GCC does not need the pushing and popping.
114*0fca6ea1SDimitry Andric //
115*0fca6ea1SDimitry Andric // TODO Remove this when the deprecated constants are removed.
116*0fca6ea1SDimitry Andric //
117*0fca6ea1SDimitry Andric // Note based on the post-review comments in
118*0fca6ea1SDimitry Andric // https://github.com/llvm/llvm-project/pull/80542 libc++ no longer deprecates
119*0fca6ea1SDimitry Andric // the macros. Since C libraries may start to deprecate these POSIX macros the
120*0fca6ea1SDimitry Andric // deprecation warning avoidance is kept.
121*0fca6ea1SDimitry Andric #if defined(_LIBCPP_COMPILER_CLANG_BASED)
122*0fca6ea1SDimitry Andric #  define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH _LIBCPP_SUPPRESS_DEPRECATED_PUSH
123*0fca6ea1SDimitry Andric #  define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP _LIBCPP_SUPPRESS_DEPRECATED_POP
124*0fca6ea1SDimitry Andric #else
125*0fca6ea1SDimitry Andric #  define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
126*0fca6ea1SDimitry Andric #  define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
127*0fca6ea1SDimitry Andric #endif
128*0fca6ea1SDimitry Andric 
12906c3fb27SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
13006c3fb27SDimitry Andric 
13106c3fb27SDimitry Andric // Some error codes are not present on all platforms, so we provide equivalents
13206c3fb27SDimitry Andric // for them:
13306c3fb27SDimitry Andric 
13406c3fb27SDimitry Andric // enum class errc
135*0fca6ea1SDimitry Andric //
136*0fca6ea1SDimitry Andric // LWG3869 deprecates the UNIX STREAMS macros and enum values.
137*0fca6ea1SDimitry Andric // This makes the code clumbersome:
138*0fca6ea1SDimitry Andric // - the enum value is deprecated and should show a diagnostic,
139*0fca6ea1SDimitry Andric // - the macro is deprecated and should _not_ show a diagnostic in this
140*0fca6ea1SDimitry Andric //   context, and
141*0fca6ea1SDimitry Andric // - the macro is not always available.
142*0fca6ea1SDimitry Andric // This leads to the odd pushing and popping of the deprecated
143*0fca6ea1SDimitry Andric // diagnostic.
144cb14a3feSDimitry Andric _LIBCPP_DECLARE_STRONG_ENUM(errc){
14506c3fb27SDimitry Andric     address_family_not_supported       = EAFNOSUPPORT,
14606c3fb27SDimitry Andric     address_in_use                     = EADDRINUSE,
14706c3fb27SDimitry Andric     address_not_available              = EADDRNOTAVAIL,
14806c3fb27SDimitry Andric     already_connected                  = EISCONN,
14906c3fb27SDimitry Andric     argument_list_too_long             = E2BIG,
15006c3fb27SDimitry Andric     argument_out_of_domain             = EDOM,
15106c3fb27SDimitry Andric     bad_address                        = EFAULT,
15206c3fb27SDimitry Andric     bad_file_descriptor                = EBADF,
15306c3fb27SDimitry Andric     bad_message                        = EBADMSG,
15406c3fb27SDimitry Andric     broken_pipe                        = EPIPE,
15506c3fb27SDimitry Andric     connection_aborted                 = ECONNABORTED,
15606c3fb27SDimitry Andric     connection_already_in_progress     = EALREADY,
15706c3fb27SDimitry Andric     connection_refused                 = ECONNREFUSED,
15806c3fb27SDimitry Andric     connection_reset                   = ECONNRESET,
15906c3fb27SDimitry Andric     cross_device_link                  = EXDEV,
16006c3fb27SDimitry Andric     destination_address_required       = EDESTADDRREQ,
16106c3fb27SDimitry Andric     device_or_resource_busy            = EBUSY,
16206c3fb27SDimitry Andric     directory_not_empty                = ENOTEMPTY,
16306c3fb27SDimitry Andric     executable_format_error            = ENOEXEC,
16406c3fb27SDimitry Andric     file_exists                        = EEXIST,
16506c3fb27SDimitry Andric     file_too_large                     = EFBIG,
16606c3fb27SDimitry Andric     filename_too_long                  = ENAMETOOLONG,
16706c3fb27SDimitry Andric     function_not_supported             = ENOSYS,
16806c3fb27SDimitry Andric     host_unreachable                   = EHOSTUNREACH,
16906c3fb27SDimitry Andric     identifier_removed                 = EIDRM,
17006c3fb27SDimitry Andric     illegal_byte_sequence              = EILSEQ,
17106c3fb27SDimitry Andric     inappropriate_io_control_operation = ENOTTY,
1721ff41cadSDimitry Andric #ifdef EINTEGRITY
17346c59ea9SDimitry Andric     integrity_check_failed             = EINTEGRITY, // FreeBSD customization
1741ff41cadSDimitry Andric #endif
17506c3fb27SDimitry Andric     interrupted                        = EINTR,
17606c3fb27SDimitry Andric     invalid_argument                   = EINVAL,
17706c3fb27SDimitry Andric     invalid_seek                       = ESPIPE,
17806c3fb27SDimitry Andric     io_error                           = EIO,
17906c3fb27SDimitry Andric     is_a_directory                     = EISDIR,
18006c3fb27SDimitry Andric     message_size                       = EMSGSIZE,
18106c3fb27SDimitry Andric     network_down                       = ENETDOWN,
18206c3fb27SDimitry Andric     network_reset                      = ENETRESET,
18306c3fb27SDimitry Andric     network_unreachable                = ENETUNREACH,
18406c3fb27SDimitry Andric     no_buffer_space                    = ENOBUFS,
18506c3fb27SDimitry Andric     no_child_process                   = ECHILD,
18606c3fb27SDimitry Andric     no_link                            = ENOLINK,
18706c3fb27SDimitry Andric     no_lock_available                  = ENOLCK,
188*0fca6ea1SDimitry Andric     // clang-format off
189*0fca6ea1SDimitry Andric     no_message_available _LIBCPP_DEPRECATED =
190*0fca6ea1SDimitry Andric     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
19106c3fb27SDimitry Andric #ifdef ENODATA
192*0fca6ea1SDimitry Andric                                               ENODATA
19306c3fb27SDimitry Andric #else
194*0fca6ea1SDimitry Andric                                               ENOMSG
19506c3fb27SDimitry Andric #endif
196*0fca6ea1SDimitry Andric     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
197*0fca6ea1SDimitry Andric     ,
198*0fca6ea1SDimitry Andric     // clang-format on
19906c3fb27SDimitry Andric     no_message         = ENOMSG,
20006c3fb27SDimitry Andric     no_protocol_option = ENOPROTOOPT,
20106c3fb27SDimitry Andric     no_space_on_device = ENOSPC,
202*0fca6ea1SDimitry Andric     // clang-format off
203*0fca6ea1SDimitry Andric     no_stream_resources _LIBCPP_DEPRECATED =
204*0fca6ea1SDimitry Andric     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
20506c3fb27SDimitry Andric #ifdef ENOSR
206*0fca6ea1SDimitry Andric                                               ENOSR
20706c3fb27SDimitry Andric #else
208*0fca6ea1SDimitry Andric                                               ENOMEM
20906c3fb27SDimitry Andric #endif
210*0fca6ea1SDimitry Andric     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
211*0fca6ea1SDimitry Andric     ,
212*0fca6ea1SDimitry Andric     // clang-format on
21306c3fb27SDimitry Andric     no_such_device_or_address = ENXIO,
21406c3fb27SDimitry Andric     no_such_device            = ENODEV,
21506c3fb27SDimitry Andric     no_such_file_or_directory = ENOENT,
21606c3fb27SDimitry Andric     no_such_process           = ESRCH,
21706c3fb27SDimitry Andric     not_a_directory           = ENOTDIR,
21806c3fb27SDimitry Andric     not_a_socket              = ENOTSOCK,
219*0fca6ea1SDimitry Andric     // clang-format off
220*0fca6ea1SDimitry Andric     not_a_stream _LIBCPP_DEPRECATED =
221*0fca6ea1SDimitry Andric     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
22206c3fb27SDimitry Andric #ifdef ENOSTR
223*0fca6ea1SDimitry Andric                                       ENOSTR
22406c3fb27SDimitry Andric #else
225*0fca6ea1SDimitry Andric                                       EINVAL
22606c3fb27SDimitry Andric #endif
227*0fca6ea1SDimitry Andric     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
228*0fca6ea1SDimitry Andric     ,
229*0fca6ea1SDimitry Andric     // clang-format on
23006c3fb27SDimitry Andric     not_connected                  = ENOTCONN,
23106c3fb27SDimitry Andric     not_enough_memory              = ENOMEM,
23206c3fb27SDimitry Andric     not_supported                  = ENOTSUP,
23306c3fb27SDimitry Andric     operation_canceled             = ECANCELED,
23406c3fb27SDimitry Andric     operation_in_progress          = EINPROGRESS,
23506c3fb27SDimitry Andric     operation_not_permitted        = EPERM,
23606c3fb27SDimitry Andric     operation_not_supported        = EOPNOTSUPP,
23706c3fb27SDimitry Andric     operation_would_block          = EWOULDBLOCK,
23806c3fb27SDimitry Andric     owner_dead                     = EOWNERDEAD,
23906c3fb27SDimitry Andric     permission_denied              = EACCES,
24006c3fb27SDimitry Andric     protocol_error                 = EPROTO,
24106c3fb27SDimitry Andric     protocol_not_supported         = EPROTONOSUPPORT,
24206c3fb27SDimitry Andric     read_only_file_system          = EROFS,
24306c3fb27SDimitry Andric     resource_deadlock_would_occur  = EDEADLK,
24406c3fb27SDimitry Andric     resource_unavailable_try_again = EAGAIN,
24506c3fb27SDimitry Andric     result_out_of_range            = ERANGE,
24606c3fb27SDimitry Andric     state_not_recoverable          = ENOTRECOVERABLE,
247*0fca6ea1SDimitry Andric     // clang-format off
248*0fca6ea1SDimitry Andric     stream_timeout _LIBCPP_DEPRECATED =
249*0fca6ea1SDimitry Andric     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
25006c3fb27SDimitry Andric #ifdef ETIME
251*0fca6ea1SDimitry Andric                                         ETIME
25206c3fb27SDimitry Andric #else
253*0fca6ea1SDimitry Andric                                         ETIMEDOUT
25406c3fb27SDimitry Andric #endif
255*0fca6ea1SDimitry Andric     _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
256*0fca6ea1SDimitry Andric     ,
257*0fca6ea1SDimitry Andric     // clang-format on
25806c3fb27SDimitry Andric     text_file_busy                = ETXTBSY,
25906c3fb27SDimitry Andric     timed_out                     = ETIMEDOUT,
26006c3fb27SDimitry Andric     too_many_files_open_in_system = ENFILE,
26106c3fb27SDimitry Andric     too_many_files_open           = EMFILE,
26206c3fb27SDimitry Andric     too_many_links                = EMLINK,
26306c3fb27SDimitry Andric     too_many_symbolic_link_levels = ELOOP,
26406c3fb27SDimitry Andric     value_too_large               = EOVERFLOW,
265cb14a3feSDimitry Andric     wrong_protocol_type           = EPROTOTYPE};
26606c3fb27SDimitry Andric _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
26706c3fb27SDimitry Andric 
26806c3fb27SDimitry Andric _LIBCPP_END_NAMESPACE_STD
26906c3fb27SDimitry Andric 
27006c3fb27SDimitry Andric #endif // _LIBCPP___ERRC
271