@@ -58,18 +58,18 @@ enum class errc
58
58
no_child_process, // ECHILD
59
59
no_link, // ENOLINK
60
60
no_lock_available, // ENOLCK
61
- no_message_available, // ENODATA
61
+ no_message_available, // ENODATA // deprecated
62
62
no_message, // ENOMSG
63
63
no_protocol_option, // ENOPROTOOPT
64
64
no_space_on_device, // ENOSPC
65
- no_stream_resources, // ENOSR
65
+ no_stream_resources, // ENOSR // deprecated
66
66
no_such_device_or_address, // ENXIO
67
67
no_such_device, // ENODEV
68
68
no_such_file_or_directory, // ENOENT
69
69
no_such_process, // ESRCH
70
70
not_a_directory, // ENOTDIR
71
71
not_a_socket, // ENOTSOCK
72
- not_a_stream, // ENOSTR
72
+ not_a_stream, // ENOSTR // deprecated
73
73
not_connected, // ENOTCONN
74
74
not_enough_memory, // ENOMEM
75
75
not_supported, // ENOTSUP
@@ -87,7 +87,7 @@ enum class errc
87
87
resource_unavailable_try_again, // EAGAIN
88
88
result_out_of_range, // ERANGE
89
89
state_not_recoverable, // ENOTRECOVERABLE
90
- stream_timeout, // ETIME
90
+ stream_timeout, // ETIME // deprecated
91
91
text_file_busy, // ETXTBSY
92
92
timed_out, // ETIMEDOUT
93
93
too_many_files_open_in_system, // ENFILE
@@ -107,12 +107,34 @@ enum class errc
107
107
# pragma GCC system_header
108
108
#endif
109
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
+ #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
+
110
123
_LIBCPP_BEGIN_NAMESPACE_STD
111
124
112
125
// Some error codes are not present on all platforms, so we provide equivalents
113
126
// for them:
114
127
115
128
// 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.
116
138
_LIBCPP_DECLARE_STRONG_ENUM (errc){
117
139
address_family_not_supported = EAFNOSUPPORT,
118
140
address_in_use = EADDRINUSE,
@@ -154,30 +176,48 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){
154
176
no_child_process = ECHILD,
155
177
no_link = ENOLINK,
156
178
no_lock_available = ENOLCK,
179
+ // clang-format off
180
+ no_message_available _LIBCPP_DEPRECATED =
181
+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
157
182
#ifdef ENODATA
158
- no_message_available = ENODATA,
183
+ ENODATA
159
184
#else
160
- no_message_available = ENOMSG,
185
+ ENOMSG
161
186
#endif
187
+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
188
+ ,
189
+ // clang-format on
162
190
no_message = ENOMSG,
163
191
no_protocol_option = ENOPROTOOPT,
164
192
no_space_on_device = ENOSPC,
193
+ // clang-format off
194
+ no_stream_resources _LIBCPP_DEPRECATED =
195
+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
165
196
#ifdef ENOSR
166
- no_stream_resources = ENOSR,
197
+ ENOSR
167
198
#else
168
- no_stream_resources = ENOMEM,
199
+ ENOMEM
169
200
#endif
201
+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
202
+ ,
203
+ // clang-format on
170
204
no_such_device_or_address = ENXIO,
171
205
no_such_device = ENODEV,
172
206
no_such_file_or_directory = ENOENT,
173
207
no_such_process = ESRCH,
174
208
not_a_directory = ENOTDIR,
175
209
not_a_socket = ENOTSOCK,
210
+ // clang-format off
211
+ not_a_stream _LIBCPP_DEPRECATED =
212
+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
176
213
#ifdef ENOSTR
177
- not_a_stream = ENOSTR,
214
+ ENOSTR
178
215
#else
179
- not_a_stream = EINVAL,
216
+ EINVAL
180
217
#endif
218
+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
219
+ ,
220
+ // clang-format on
181
221
not_connected = ENOTCONN,
182
222
not_enough_memory = ENOMEM,
183
223
not_supported = ENOTSUP,
@@ -195,11 +235,17 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){
195
235
resource_unavailable_try_again = EAGAIN,
196
236
result_out_of_range = ERANGE,
197
237
state_not_recoverable = ENOTRECOVERABLE,
238
+ // clang-format off
239
+ stream_timeout _LIBCPP_DEPRECATED =
240
+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
198
241
#ifdef ETIME
199
- stream_timeout = ETIME,
242
+ ETIME
200
243
#else
201
- stream_timeout = ETIMEDOUT,
244
+ ETIMEDOUT
202
245
#endif
246
+ _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
247
+ ,
248
+ // clang-format on
203
249
text_file_busy = ETXTBSY,
204
250
timed_out = ETIMEDOUT,
205
251
too_many_files_open_in_system = ENFILE,
0 commit comments