1// -*- C++ -*-
2//===---------------------------- __errc ----------------------------------===//
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
16namespace std
17{
18
19enum 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
62    no_message,                         // ENOMSG
63    no_protocol_option,                 // ENOPROTOOPT
64    no_space_on_device,                 // ENOSPC
65    no_stream_resources,                // ENOSR
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
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
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_LIBCPP_BEGIN_NAMESPACE_STD
111
112// Some error codes are not present on all platforms, so we provide equivalents
113// for them:
114
115//enum class errc
116_LIBCPP_DECLARE_STRONG_ENUM(errc)
117{
118    address_family_not_supported        = EAFNOSUPPORT,
119    address_in_use                      = EADDRINUSE,
120    address_not_available               = EADDRNOTAVAIL,
121    already_connected                   = EISCONN,
122    argument_list_too_long              = E2BIG,
123    argument_out_of_domain              = EDOM,
124    bad_address                         = EFAULT,
125    bad_file_descriptor                 = EBADF,
126    bad_message                         = EBADMSG,
127    broken_pipe                         = EPIPE,
128    connection_aborted                  = ECONNABORTED,
129    connection_already_in_progress      = EALREADY,
130    connection_refused                  = ECONNREFUSED,
131    connection_reset                    = ECONNRESET,
132    cross_device_link                   = EXDEV,
133    destination_address_required        = EDESTADDRREQ,
134    device_or_resource_busy             = EBUSY,
135    directory_not_empty                 = ENOTEMPTY,
136    executable_format_error             = ENOEXEC,
137    file_exists                         = EEXIST,
138    file_too_large                      = EFBIG,
139    filename_too_long                   = ENAMETOOLONG,
140    function_not_supported              = ENOSYS,
141    host_unreachable                    = EHOSTUNREACH,
142    identifier_removed                  = EIDRM,
143    illegal_byte_sequence               = EILSEQ,
144    inappropriate_io_control_operation  = ENOTTY,
145    interrupted                         = EINTR,
146    invalid_argument                    = EINVAL,
147    invalid_seek                        = ESPIPE,
148    io_error                            = EIO,
149    is_a_directory                      = EISDIR,
150    message_size                        = EMSGSIZE,
151    network_down                        = ENETDOWN,
152    network_reset                       = ENETRESET,
153    network_unreachable                 = ENETUNREACH,
154    no_buffer_space                     = ENOBUFS,
155    no_child_process                    = ECHILD,
156    no_link                             = ENOLINK,
157    no_lock_available                   = ENOLCK,
158#ifdef ENODATA
159    no_message_available                = ENODATA,
160#else
161    no_message_available                = ENOMSG,
162#endif
163    no_message                          = ENOMSG,
164    no_protocol_option                  = ENOPROTOOPT,
165    no_space_on_device                  = ENOSPC,
166#ifdef ENOSR
167    no_stream_resources                 = ENOSR,
168#else
169    no_stream_resources                 = ENOMEM,
170#endif
171    no_such_device_or_address           = ENXIO,
172    no_such_device                      = ENODEV,
173    no_such_file_or_directory           = ENOENT,
174    no_such_process                     = ESRCH,
175    not_a_directory                     = ENOTDIR,
176    not_a_socket                        = ENOTSOCK,
177#ifdef ENOSTR
178    not_a_stream                        = ENOSTR,
179#else
180    not_a_stream                        = EINVAL,
181#endif
182    not_connected                       = ENOTCONN,
183    not_enough_memory                   = ENOMEM,
184    not_supported                       = ENOTSUP,
185    operation_canceled                  = ECANCELED,
186    operation_in_progress               = EINPROGRESS,
187    operation_not_permitted             = EPERM,
188    operation_not_supported             = EOPNOTSUPP,
189    operation_would_block               = EWOULDBLOCK,
190    owner_dead                          = EOWNERDEAD,
191    permission_denied                   = EACCES,
192    protocol_error                      = EPROTO,
193    protocol_not_supported              = EPROTONOSUPPORT,
194    read_only_file_system               = EROFS,
195    resource_deadlock_would_occur       = EDEADLK,
196    resource_unavailable_try_again      = EAGAIN,
197    result_out_of_range                 = ERANGE,
198    state_not_recoverable               = ENOTRECOVERABLE,
199#ifdef ETIME
200    stream_timeout                      = ETIME,
201#else
202    stream_timeout                      = ETIMEDOUT,
203#endif
204    text_file_busy                      = ETXTBSY,
205    timed_out                           = ETIMEDOUT,
206    too_many_files_open_in_system       = ENFILE,
207    too_many_files_open                 = EMFILE,
208    too_many_links                      = EMLINK,
209    too_many_symbolic_link_levels       = ELOOP,
210    value_too_large                     = EOVERFLOW,
211    wrong_protocol_type                 = EPROTOTYPE
212};
213_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc)
214
215_LIBCPP_END_NAMESPACE_STD
216
217#endif  // _LIBCPP___ERRC
218