VirtualBox

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

最後變更 在這個檔案從96270是 96270,由 vboxsync 提交於 3 年 前

IPRT/nocrt: Release build fixes. bugref:10261

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette