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