VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/err/nocrt-strerror.cpp

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 10.6 KB
Line 
1/* $Id: nocrt-strerror.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * IPRT - No-CRT - Convert errno value to string.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
41#define IPRT_NO_CRT_FOR_3RD_PARTY
42#include "internal/nocrt.h"
43#include <iprt/nocrt/string.h>
44#include <iprt/nocrt/errno.h>
45#include <iprt/assert.h>
46#include <iprt/log.h>
47
48
49#undef strerror
50const char *RT_NOCRT(strerror)(int iErrNo)
51{
52 /*
53 * Process error codes.
54 *
55 * (Use a switch and not a table since the numbers vary among compilers
56 * and OSes. So we let the compiler switch optimizer handle speed issues.)
57 *
58 * This switch is arranged like the Linux i386 errno.h! This switch is mirrored
59 * by RTErrConvertToErrno and RTErrConvertFromErrno.
60 */
61 switch (iErrNo)
62 { /* Linux number */
63 case 0: return "no error";
64#ifdef EPERM
65 RT_CASE_RET_STR(EPERM); /* 1 */
66#endif
67#ifdef ENOENT
68 RT_CASE_RET_STR(ENOENT);
69#endif
70#ifdef ESRCH
71 RT_CASE_RET_STR(ESRCH);
72#endif
73#ifdef EINTR
74 RT_CASE_RET_STR(EINTR);
75#endif
76#ifdef EIO
77 RT_CASE_RET_STR(EIO);
78#endif
79#ifdef ENXIO
80 RT_CASE_RET_STR(ENXIO); /** @todo fix this duplicate error */
81#endif
82#ifdef E2BIG
83 RT_CASE_RET_STR(E2BIG);
84#endif
85#ifdef ENOEXEC
86 RT_CASE_RET_STR(ENOEXEC);
87#endif
88#ifdef EBADF
89 RT_CASE_RET_STR(EBADF);
90#endif
91#ifdef ECHILD
92 RT_CASE_RET_STR(ECHILD); /* 10 */ /** @todo fix duplicate error */
93#endif
94#ifdef EAGAIN
95 RT_CASE_RET_STR(EAGAIN);
96#endif
97#ifdef ENOMEM
98 RT_CASE_RET_STR(ENOMEM);
99#endif
100#ifdef EACCES
101 RT_CASE_RET_STR(EACCES); /** @todo fix duplicate error */
102#endif
103#ifdef EFAULT
104 RT_CASE_RET_STR(EFAULT);
105#endif
106#ifdef ENOTBLK
107 RT_CASE_RET_STR(ENOTBLK);
108#endif
109#ifdef EBUSY
110 RT_CASE_RET_STR(EBUSY);
111#endif
112#ifdef EEXIST
113 RT_CASE_RET_STR(EEXIST);
114#endif
115#ifdef EXDEV
116 RT_CASE_RET_STR(EXDEV);
117#endif
118#ifdef ENODEV
119 RT_CASE_RET_STR(ENODEV); /** @todo fix duplicate error */
120#endif
121#ifdef ENOTDIR
122 RT_CASE_RET_STR(ENOTDIR); /* 20 */
123#endif
124#ifdef EISDIR
125 RT_CASE_RET_STR(EISDIR);
126#endif
127#ifdef EINVAL
128 RT_CASE_RET_STR(EINVAL);
129#endif
130#ifdef ENFILE
131 RT_CASE_RET_STR(ENFILE); /** @todo fix duplicate error */
132#endif
133#ifdef EMFILE
134 RT_CASE_RET_STR(EMFILE);
135#endif
136#ifdef ENOTTY
137 RT_CASE_RET_STR(ENOTTY);
138#endif
139#ifdef ETXTBSY
140 RT_CASE_RET_STR(ETXTBSY);
141#endif
142#ifdef EFBIG
143 RT_CASE_RET_STR(EFBIG);
144#endif
145#ifdef ENOSPC
146 RT_CASE_RET_STR(ENOSPC);
147#endif
148#ifdef ESPIPE
149 RT_CASE_RET_STR(ESPIPE);
150#endif
151#ifdef EROFS
152 RT_CASE_RET_STR(EROFS); /* 30 */
153#endif
154#ifdef EMLINK
155 RT_CASE_RET_STR(EMLINK);
156#endif
157#ifdef EPIPE
158 RT_CASE_RET_STR(EPIPE);
159#endif
160#ifdef EDOM
161 RT_CASE_RET_STR(EDOM); /** @todo fix duplicate error */
162#endif
163#ifdef ERANGE
164 RT_CASE_RET_STR(ERANGE); /** @todo fix duplicate error */
165#endif
166#ifdef EDEADLK
167 RT_CASE_RET_STR(EDEADLK);
168#endif
169#ifdef ENAMETOOLONG
170 RT_CASE_RET_STR(ENAMETOOLONG);
171#endif
172#ifdef ENOLCK
173 RT_CASE_RET_STR(ENOLCK);
174#endif
175#ifdef ENOSYS /** @todo map this differently on solaris. */
176 RT_CASE_RET_STR(ENOSYS);
177#endif
178#ifdef ENOTEMPTY
179 RT_CASE_RET_STR(ENOTEMPTY);
180#endif
181#ifdef ELOOP
182 RT_CASE_RET_STR(ELOOP); /* 40 */
183#endif
184 //41??
185#ifdef ENOMSG
186 RT_CASE_RET_STR(ENOMSG);
187#endif
188#ifdef EIDRM
189 RT_CASE_RET_STR(EIDRM);
190#endif
191#ifdef ECHRNG
192 RT_CASE_RET_STR(ECHRNG);
193#endif
194#ifdef EL2NSYNC
195 RT_CASE_RET_STR(EL2NSYNC);
196#endif
197#ifdef EL3HLT
198 RT_CASE_RET_STR(EL3HLT);
199#endif
200#ifdef EL3RST
201 RT_CASE_RET_STR(EL3RST);
202#endif
203#ifdef ELNRNG
204 RT_CASE_RET_STR(ELNRNG);
205#endif
206#ifdef EUNATCH
207 RT_CASE_RET_STR(EUNATCH);
208#endif
209#ifdef ENOCSI
210 RT_CASE_RET_STR(ENOCSI);
211#endif
212#ifdef EL2HLT
213 RT_CASE_RET_STR(EL2HLT);
214#endif
215#ifdef EBADE
216 RT_CASE_RET_STR(EBADE);
217#endif
218#ifdef EBADR
219 RT_CASE_RET_STR(EBADR);
220#endif
221#ifdef EXFULL
222 RT_CASE_RET_STR(EXFULL);
223#endif
224#ifdef ENOANO
225 RT_CASE_RET_STR(ENOANO);
226#endif
227#ifdef EBADRQC
228 RT_CASE_RET_STR(EBADRQC);
229#endif
230#ifdef EBADSLT
231 RT_CASE_RET_STR(EBADSLT);
232#endif
233 //case 58:
234#ifdef EBFONT
235 RT_CASE_RET_STR(EBFONT);
236#endif
237#ifdef ENOSTR
238 RT_CASE_RET_STR(ENOSTR);
239#endif
240#ifdef ENODATA
241 RT_CASE_RET_STR(ENODATA);
242#endif
243#ifdef ETIME
244 RT_CASE_RET_STR(ETIME);
245#endif
246#ifdef ENOSR
247 RT_CASE_RET_STR(ENOSR);
248#endif
249#ifdef ENONET
250 RT_CASE_RET_STR(ENONET);
251#endif
252#ifdef ENOPKG
253 RT_CASE_RET_STR(ENOPKG);
254#endif
255#ifdef EREMOTE
256 RT_CASE_RET_STR(EREMOTE);
257#endif
258#ifdef ENOLINK
259 RT_CASE_RET_STR(ENOLINK);
260#endif
261#ifdef EADV
262 RT_CASE_RET_STR(EADV);
263#endif
264#ifdef ESRMNT
265 RT_CASE_RET_STR(ESRMNT);
266#endif
267#ifdef ECOMM
268 RT_CASE_RET_STR(ECOMM);
269#endif
270#ifdef EPROTO
271 RT_CASE_RET_STR(EPROTO);
272#endif
273#ifdef EMULTIHOP
274 RT_CASE_RET_STR(EMULTIHOP);
275#endif
276#ifdef EDOTDOT
277 RT_CASE_RET_STR(EDOTDOT);
278#endif
279#ifdef EBADMSG
280 RT_CASE_RET_STR(EBADMSG);
281#endif
282#ifdef EOVERFLOW
283 RT_CASE_RET_STR(EOVERFLOW); /** @todo fix duplicate error? */
284#endif
285#ifdef ENOTUNIQ
286 RT_CASE_RET_STR(ENOTUNIQ);
287#endif
288#ifdef EBADFD
289 RT_CASE_RET_STR(EBADFD); /** @todo fix duplicate error? */
290#endif
291#ifdef EREMCHG
292 RT_CASE_RET_STR(EREMCHG);
293#endif
294#ifdef ELIBACC
295 RT_CASE_RET_STR(ELIBACC);
296#endif
297#ifdef ELIBBAD
298 RT_CASE_RET_STR(ELIBBAD);
299#endif
300#ifdef ELIBSCN
301 RT_CASE_RET_STR(ELIBSCN);
302#endif
303#ifdef ELIBMAX
304 RT_CASE_RET_STR(ELIBMAX);
305#endif
306#ifdef ELIBEXEC
307 RT_CASE_RET_STR(ELIBEXEC);
308#endif
309#ifdef EILSEQ
310 RT_CASE_RET_STR(EILSEQ);
311#endif
312#ifdef ERESTART
313 RT_CASE_RET_STR(ERESTART);/** @todo fix duplicate error?*/
314#endif
315#ifdef ESTRPIPE
316 RT_CASE_RET_STR(ESTRPIPE);
317#endif
318#ifdef EUSERS
319 RT_CASE_RET_STR(EUSERS);
320#endif
321#ifdef ENOTSOCK
322 RT_CASE_RET_STR(ENOTSOCK);
323#endif
324#ifdef EDESTADDRREQ
325 RT_CASE_RET_STR(EDESTADDRREQ);
326#endif
327#ifdef EMSGSIZE
328 RT_CASE_RET_STR(EMSGSIZE);
329#endif
330#ifdef EPROTOTYPE
331 RT_CASE_RET_STR(EPROTOTYPE);
332#endif
333#ifdef ENOPROTOOPT
334 RT_CASE_RET_STR(ENOPROTOOPT);
335#endif
336#ifdef EPROTONOSUPPORT
337 RT_CASE_RET_STR(EPROTONOSUPPORT);
338#endif
339#ifdef ESOCKTNOSUPPORT
340 RT_CASE_RET_STR(ESOCKTNOSUPPORT);
341#endif
342#ifdef EOPNOTSUPP /** @todo map this differently on solaris. */
343 RT_CASE_RET_STR(EOPNOTSUPP);
344#endif
345#ifdef EPFNOSUPPORT
346 RT_CASE_RET_STR(EPFNOSUPPORT);
347#endif
348#ifdef EAFNOSUPPORT
349 RT_CASE_RET_STR(EAFNOSUPPORT);
350#endif
351#ifdef EADDRINUSE
352 RT_CASE_RET_STR(EADDRINUSE);
353#endif
354#ifdef EADDRNOTAVAIL
355 RT_CASE_RET_STR(EADDRNOTAVAIL);
356#endif
357#ifdef ENETDOWN
358 RT_CASE_RET_STR(ENETDOWN);
359#endif
360#ifdef ENETUNREACH
361 RT_CASE_RET_STR(ENETUNREACH);
362#endif
363#ifdef ENETRESET
364 RT_CASE_RET_STR(ENETRESET);
365#endif
366#ifdef ECONNABORTED
367 RT_CASE_RET_STR(ECONNABORTED);
368#endif
369#ifdef ECONNRESET
370 RT_CASE_RET_STR(ECONNRESET);
371#endif
372#ifdef ENOBUFS
373 RT_CASE_RET_STR(ENOBUFS);
374#endif
375#ifdef EISCONN
376 RT_CASE_RET_STR(EISCONN);
377#endif
378#ifdef ENOTCONN
379 RT_CASE_RET_STR(ENOTCONN);
380#endif
381#ifdef ESHUTDOWN
382 RT_CASE_RET_STR(ESHUTDOWN);
383#endif
384#ifdef ETOOMANYREFS
385 RT_CASE_RET_STR(ETOOMANYREFS);
386#endif
387#ifdef ETIMEDOUT
388 RT_CASE_RET_STR(ETIMEDOUT);
389#endif
390#ifdef ECONNREFUSED
391 RT_CASE_RET_STR(ECONNREFUSED);
392#endif
393#ifdef EHOSTDOWN
394 RT_CASE_RET_STR(EHOSTDOWN);
395#endif
396#ifdef EHOSTUNREACH
397 RT_CASE_RET_STR(EHOSTUNREACH);
398#endif
399#ifdef EALREADY
400# if !defined(ENOLCK) || (EALREADY != ENOLCK)
401 RT_CASE_RET_STR(EALREADY);
402# endif
403#endif
404#ifdef EINPROGRESS
405# if !defined(ENODEV) || (EINPROGRESS != ENODEV)
406 RT_CASE_RET_STR(EINPROGRESS);
407# endif
408#endif
409#ifdef ESTALE
410 RT_CASE_RET_STR(ESTALE); /* 116: Stale NFS file handle */
411#endif
412#ifdef EUCLEAN
413 RT_CASE_RET_STR(EUCLEAN);
414#endif
415#ifdef ENOTNAM
416 RT_CASE_RET_STR(ENOTNAM);
417#endif
418#ifdef ENAVAIL
419 RT_CASE_RET_STR(ENAVAIL);
420#endif
421#ifdef EISNAM
422 RT_CASE_RET_STR(EISNAM);
423#endif
424#ifdef EREMOTEIO
425 RT_CASE_RET_STR(EREMOTEIO);
426#endif
427#ifdef EDQUOT
428 RT_CASE_RET_STR(EDQUOT); /** @todo fix duplicate error */
429#endif
430#ifdef ENOMEDIUM
431 RT_CASE_RET_STR(ENOMEDIUM);
432#endif
433#ifdef EMEDIUMTYPE
434 RT_CASE_RET_STR(EMEDIUMTYPE);
435#endif
436#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
437 RT_CASE_RET_STR(EWOULDBLOCK);
438#endif
439
440 /* Non-linux */
441
442#ifdef EPROCLIM
443 RT_CASE_RET_STR(EPROCLIM);
444#endif
445#ifdef EDOOFUS
446# if EDOOFUS != EINVAL
447 RT_CASE_RET_STR(EDOOFUS);
448# endif
449#endif
450#ifdef ENOTSUP
451# ifndef EOPNOTSUPP
452 RT_CASE_RET_STR(ENOTSUP);
453# else
454# if ENOTSUP != EOPNOTSUPP
455 RT_CASE_RET_STR(ENOTSUP);
456# endif
457# endif
458#endif
459 default:
460 AssertLogRelMsgFailedReturn(("Unhandled error code %d\n", iErrNo), "unknown-errno-value");
461 }
462}
463RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strerror);
464
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use