@@ -58,18 +58,18 @@ enum class errc
5858 no_child_process, // ECHILD
5959 no_link, // ENOLINK
6060 no_lock_available, // ENOLCK
61- no_message_available, // ENODATA
61+ no_message_available, // ENODATA // deprecated
6262 no_message, // ENOMSG
6363 no_protocol_option, // ENOPROTOOPT
6464 no_space_on_device, // ENOSPC
65- no_stream_resources, // ENOSR
65+ no_stream_resources, // ENOSR // deprecated
6666 no_such_device_or_address, // ENXIO
6767 no_such_device, // ENODEV
6868 no_such_file_or_directory, // ENOENT
6969 no_such_process, // ESRCH
7070 not_a_directory, // ENOTDIR
7171 not_a_socket, // ENOTSOCK
72- not_a_stream, // ENOSTR
72+ not_a_stream, // ENOSTR // deprecated
7373 not_connected, // ENOTCONN
7474 not_enough_memory, // ENOMEM
7575 not_supported, // ENOTSUP
@@ -87,7 +87,7 @@ enum class errc
8787 resource_unavailable_try_again, // EAGAIN
8888 result_out_of_range, // ERANGE
8989 state_not_recoverable, // ENOTRECOVERABLE
90- stream_timeout, // ETIME
90+ stream_timeout, // ETIME // deprecated
9191 text_file_busy, // ETXTBSY
9292 timed_out, // ETIMEDOUT
9393 too_many_files_open_in_system, // ENFILE
@@ -107,12 +107,34 @@ enum class errc
107107# pragma GCC system_header
108108#endif
109109
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+ #if defined(_LIBCPP_COMPILER_CLANG_BASED)
116+ # define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH _LIBCPP_SUPPRESS_DEPRECATED_PUSH
117+ # define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP _LIBCPP_SUPPRESS_DEPRECATED_POP
118+ #else
119+ # define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
120+ # define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
121+ #endif
122+
110123_LIBCPP_BEGIN_NAMESPACE_STD
111124
112125// Some error codes are not present on all platforms, so we provide equivalents
113126// for them:
114127
115128// enum class errc
129+ //
130+ // LWG3869 deprecates the UNIX STREAMS macros and enum values.
131+ // This makes the code clumbersome:
132+ // - the enum value is deprecated and should show a diagnostic,
133+ // - the macro is deprecated and should _not_ show a diagnostic in this
134+ // context, and
135+ // - the macro is not always available.
136+ // This leads to the odd pushing and popping of the deprecated
137+ // diagnostic.
116138_LIBCPP_DECLARE_STRONG_ENUM (errc){
117139 address_family_not_supported = EAFNOSUPPORT,
118140 address_in_use = EADDRINUSE,
@@ -154,30 +176,48 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){
154176 no_child_process = ECHILD,
155177 no_link = ENOLINK,
156178 no_lock_available = ENOLCK,
179+ // clang-format off
180+ no_message_available _LIBCPP_DEPRECATED =
181+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
157182#ifdef ENODATA
158- no_message_available = ENODATA,
183+ ENODATA
159184#else
160- no_message_available = ENOMSG,
185+ ENOMSG
161186#endif
187+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
188+ ,
189+ // clang-format on
162190 no_message = ENOMSG,
163191 no_protocol_option = ENOPROTOOPT,
164192 no_space_on_device = ENOSPC,
193+ // clang-format off
194+ no_stream_resources _LIBCPP_DEPRECATED =
195+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
165196#ifdef ENOSR
166- no_stream_resources = ENOSR,
197+ ENOSR
167198#else
168- no_stream_resources = ENOMEM,
199+ ENOMEM
169200#endif
201+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
202+ ,
203+ // clang-format on
170204 no_such_device_or_address = ENXIO,
171205 no_such_device = ENODEV,
172206 no_such_file_or_directory = ENOENT,
173207 no_such_process = ESRCH,
174208 not_a_directory = ENOTDIR,
175209 not_a_socket = ENOTSOCK,
210+ // clang-format off
211+ not_a_stream _LIBCPP_DEPRECATED =
212+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
176213#ifdef ENOSTR
177- not_a_stream = ENOSTR,
214+ ENOSTR
178215#else
179- not_a_stream = EINVAL,
216+ EINVAL
180217#endif
218+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
219+ ,
220+ // clang-format on
181221 not_connected = ENOTCONN,
182222 not_enough_memory = ENOMEM,
183223 not_supported = ENOTSUP,
@@ -195,11 +235,17 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){
195235 resource_unavailable_try_again = EAGAIN,
196236 result_out_of_range = ERANGE,
197237 state_not_recoverable = ENOTRECOVERABLE,
238+ // clang-format off
239+ stream_timeout _LIBCPP_DEPRECATED =
240+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
198241#ifdef ETIME
199- stream_timeout = ETIME,
242+ ETIME
200243#else
201- stream_timeout = ETIMEDOUT,
244+ ETIMEDOUT
202245#endif
246+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
247+ ,
248+ // clang-format on
203249 text_file_busy = ETXTBSY,
204250 timed_out = ETIMEDOUT,
205251 too_many_files_open_in_system = ENFILE,
0 commit comments