267 lines · c
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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP___ERRC11#define _LIBCPP___ERRC12 13/*14 system_error synopsis15 16namespace std17{18 19enum class errc20{21 address_family_not_supported, // EAFNOSUPPORT22 address_in_use, // EADDRINUSE23 address_not_available, // EADDRNOTAVAIL24 already_connected, // EISCONN25 argument_list_too_long, // E2BIG26 argument_out_of_domain, // EDOM27 bad_address, // EFAULT28 bad_file_descriptor, // EBADF29 bad_message, // EBADMSG30 broken_pipe, // EPIPE31 connection_aborted, // ECONNABORTED32 connection_already_in_progress, // EALREADY33 connection_refused, // ECONNREFUSED34 connection_reset, // ECONNRESET35 cross_device_link, // EXDEV36 destination_address_required, // EDESTADDRREQ37 device_or_resource_busy, // EBUSY38 directory_not_empty, // ENOTEMPTY39 executable_format_error, // ENOEXEC40 file_exists, // EEXIST41 file_too_large, // EFBIG42 filename_too_long, // ENAMETOOLONG43 function_not_supported, // ENOSYS44 host_unreachable, // EHOSTUNREACH45 identifier_removed, // EIDRM46 illegal_byte_sequence, // EILSEQ47 inappropriate_io_control_operation, // ENOTTY48 interrupted, // EINTR49 invalid_argument, // EINVAL50 invalid_seek, // ESPIPE51 io_error, // EIO52 is_a_directory, // EISDIR53 message_size, // EMSGSIZE54 network_down, // ENETDOWN55 network_reset, // ENETRESET56 network_unreachable, // ENETUNREACH57 no_buffer_space, // ENOBUFS58 no_child_process, // ECHILD59 no_link, // ENOLINK60 no_lock_available, // ENOLCK61 no_message_available, // ENODATA // deprecated62 no_message, // ENOMSG63 no_protocol_option, // ENOPROTOOPT64 no_space_on_device, // ENOSPC65 no_stream_resources, // ENOSR // deprecated66 no_such_device_or_address, // ENXIO67 no_such_device, // ENODEV68 no_such_file_or_directory, // ENOENT69 no_such_process, // ESRCH70 not_a_directory, // ENOTDIR71 not_a_socket, // ENOTSOCK72 not_a_stream, // ENOSTR // deprecated73 not_connected, // ENOTCONN74 not_enough_memory, // ENOMEM75 not_supported, // ENOTSUP76 operation_canceled, // ECANCELED77 operation_in_progress, // EINPROGRESS78 operation_not_permitted, // EPERM79 operation_not_supported, // EOPNOTSUPP80 operation_would_block, // EWOULDBLOCK81 owner_dead, // EOWNERDEAD82 permission_denied, // EACCES83 protocol_error, // EPROTO84 protocol_not_supported, // EPROTONOSUPPORT85 read_only_file_system, // EROFS86 resource_deadlock_would_occur, // EDEADLK87 resource_unavailable_try_again, // EAGAIN88 result_out_of_range, // ERANGE89 state_not_recoverable, // ENOTRECOVERABLE90 stream_timeout, // ETIME // deprecated91 text_file_busy, // ETXTBSY92 timed_out, // ETIMEDOUT93 too_many_files_open_in_system, // ENFILE94 too_many_files_open, // EMFILE95 too_many_links, // EMLINK96 too_many_symbolic_link_levels, // ELOOP97 value_too_large, // EOVERFLOW98 wrong_protocol_type // EPROTOTYPE99};100 101*/102 103#include <__config>104#include <cerrno>105 106#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)107# pragma GCC system_header108#endif109 110// The method of pushing and popping the diagnostics fails for GCC. GCC does111// not recognize the pragma's used to generate deprecated diagnostics for112// 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 in117// https://github.com/llvm/llvm-project/pull/80542 libc++ no longer deprecates118// the macros. Since C libraries may start to deprecate these POSIX macros the119// deprecation warning avoidance is kept.120#if defined(_LIBCPP_COMPILER_CLANG_BASED)121# define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH _LIBCPP_SUPPRESS_DEPRECATED_PUSH122# define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP _LIBCPP_SUPPRESS_DEPRECATED_POP123#else124# define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH125# define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP126#endif127 128_LIBCPP_BEGIN_NAMESPACE_STD129 130// Some error codes are not present on all platforms, so we provide equivalents131// for them:132 133// enum class errc134//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 this139// context, and140// - the macro is not always available.141// This leads to the odd pushing and popping of the deprecated142// 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 off185 no_message_available _LIBCPP_DEPRECATED =186 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH187#ifdef ENODATA188 ENODATA189#else190 ENOMSG191#endif192 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP193 ,194 // clang-format on195 no_message = ENOMSG,196 no_protocol_option = ENOPROTOOPT,197 no_space_on_device = ENOSPC,198 // clang-format off199 no_stream_resources _LIBCPP_DEPRECATED =200 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH201#ifdef ENOSR202 ENOSR203#else204 ENOMEM205#endif206 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP207 ,208 // clang-format on209 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 off216 not_a_stream _LIBCPP_DEPRECATED =217 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH218#ifdef ENOSTR219 ENOSTR220#else221 EINVAL222#endif223 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP224 ,225 // clang-format on226 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 off244 stream_timeout _LIBCPP_DEPRECATED =245 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH246#ifdef ETIME247 ETIME248#else249 ETIMEDOUT250#endif251 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP252 ,253 // clang-format on254 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_STD265 266#endif // _LIBCPP___ERRC267