errc.h 10 KB

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