1 /*
2  * Copyright (c) 2006-2022, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2021-05-22     Meco Man     The first version.
9  */
10 
11 #ifndef __SYS_ERRNO_H__
12 #define __SYS_ERRNO_H__
13 
14 #if defined(__ARMCC_VERSION)
15 /*
16 defined in armcc/errno.h
17 
18 #define EDOM    1
19 #define ERANGE  2
20 #define EILSEQ  4
21 #define ESIGNUM 3
22 #define EINVAL  5
23 #define ENOMEM  6
24 */
25 
26 #define ERROR_BASE_NO    7
27 
28 #elif defined(__IAR_SYSTEMS_ICC__)
29 /* defined in iar/errno.h
30 #define EDOM    33
31 #define ERANGE  34
32 #define EFPOS   35
33 #define EILSEQ  36
34 */
35 #define ERROR_BASE_NO    36
36 
37 #else
38 #define ERROR_BASE_NO    0
39 #endif
40 
41 #if defined(__ARMCC_VERSION) || defined(__IAR_SYSTEMS_ICC__)
42 #include <errno.h>
43 
44 #ifndef EPERM
45 #define EPERM            (ERROR_BASE_NO + 1)
46 #endif
47 
48 #ifndef ENOENT
49 #define ENOENT           (ERROR_BASE_NO + 2)
50 #endif
51 
52 #ifndef ESRCH
53 #define ESRCH            (ERROR_BASE_NO + 3)
54 #endif
55 
56 #ifndef EINTR
57 #define EINTR            (ERROR_BASE_NO + 4)
58 #endif
59 
60 #ifndef EIO
61 #define EIO              (ERROR_BASE_NO + 5)
62 #endif
63 
64 #ifndef ENXIO
65 #define ENXIO            (ERROR_BASE_NO + 6)
66 #endif
67 
68 #ifndef E2BIG
69 #define E2BIG            (ERROR_BASE_NO + 7)
70 #endif
71 
72 #ifndef ENOEXEC
73 #define ENOEXEC          (ERROR_BASE_NO + 8)
74 #endif
75 
76 #ifndef EBADF
77 #define EBADF            (ERROR_BASE_NO + 9)
78 #endif
79 
80 #ifndef ECHILD
81 #define ECHILD          (ERROR_BASE_NO + 10)
82 #endif
83 
84 #ifndef EAGAIN
85 #define EAGAIN          (ERROR_BASE_NO + 11)
86 #endif
87 
88 #ifndef ENOMEM
89 #define ENOMEM          (ERROR_BASE_NO + 12)
90 #endif
91 
92 #ifndef EACCES
93 #define EACCES          (ERROR_BASE_NO + 13)
94 #endif
95 
96 #ifndef EFAULT
97 #define EFAULT          (ERROR_BASE_NO + 14)
98 #endif
99 
100 #ifndef ENOTBLK
101 #define ENOTBLK         (ERROR_BASE_NO + 15)
102 #endif
103 
104 #ifndef EBUSY
105 #define EBUSY           (ERROR_BASE_NO + 16)
106 #endif
107 
108 #ifndef EEXIST
109 #define EEXIST          (ERROR_BASE_NO + 17)
110 #endif
111 
112 #ifndef EXDEV
113 #define EXDEV           (ERROR_BASE_NO + 18)
114 #endif
115 
116 #ifndef ENODEV
117 #define ENODEV          (ERROR_BASE_NO + 19)
118 #endif
119 
120 #ifndef ENOTDIR
121 #define ENOTDIR         (ERROR_BASE_NO + 20)
122 #endif
123 
124 #ifndef EISDIR
125 #define EISDIR          (ERROR_BASE_NO + 21)
126 #endif
127 
128 #ifndef EINVAL
129 #define EINVAL          (ERROR_BASE_NO + 22)
130 #endif
131 
132 #ifndef ENFILE
133 #define ENFILE          (ERROR_BASE_NO + 23)
134 #endif
135 
136 #ifndef EMFILE
137 #define EMFILE          (ERROR_BASE_NO + 24)
138 #endif
139 
140 #ifndef ENOTTY
141 #define ENOTTY          (ERROR_BASE_NO + 25)
142 #endif
143 
144 #ifndef ETXTBSY
145 #define ETXTBSY         (ERROR_BASE_NO + 26)
146 #endif
147 
148 #ifndef EFBIG
149 #define EFBIG           (ERROR_BASE_NO + 27)
150 #endif
151 
152 #ifndef ENOSPC
153 #define ENOSPC          (ERROR_BASE_NO + 28)
154 #endif
155 
156 #ifndef ESPIPE
157 #define ESPIPE          (ERROR_BASE_NO + 29)
158 #endif
159 
160 #ifndef EROFS
161 #define EROFS           (ERROR_BASE_NO + 30)
162 #endif
163 
164 #ifndef EMLINK
165 #define EMLINK          (ERROR_BASE_NO + 31)
166 #endif
167 
168 #ifndef EPIPE
169 #define EPIPE           (ERROR_BASE_NO + 32)
170 #endif
171 
172 #ifndef EDOM
173 #define EDOM            (ERROR_BASE_NO + 33)
174 #endif
175 
176 #ifndef ERANGE
177 #define ERANGE          (ERROR_BASE_NO + 34)
178 #endif
179 
180 #ifndef EDEADLK
181 #define EDEADLK         (ERROR_BASE_NO + 35)
182 #endif
183 
184 #ifndef ENAMETOOLONG
185 #define ENAMETOOLONG    (ERROR_BASE_NO + 36)
186 #endif
187 
188 #ifndef ENOLCK
189 #define ENOLCK          (ERROR_BASE_NO + 37)
190 #endif
191 
192 #ifndef ENOSYS
193 #define ENOSYS          (ERROR_BASE_NO + 38)
194 #endif
195 
196 #ifndef ENOTEMPTY
197 #define ENOTEMPTY       (ERROR_BASE_NO + 39)
198 #endif
199 
200 #ifndef ELOOP
201 #define ELOOP           (ERROR_BASE_NO + 40)
202 #endif
203 
204 #ifndef EWOULDBLOCK
205 #define EWOULDBLOCK     EAGAIN
206 #endif
207 
208 #ifndef ENOMSG
209 #define ENOMSG          (ERROR_BASE_NO + 42)
210 #endif
211 
212 #ifndef EIDRM
213 #define EIDRM           (ERROR_BASE_NO + 43)
214 #endif
215 
216 #ifndef ECHRNG
217 #define ECHRNG          (ERROR_BASE_NO + 44)
218 #endif
219 
220 #ifndef EL2NSYNC
221 #define EL2NSYNC        (ERROR_BASE_NO + 45)
222 #endif
223 
224 #ifndef EL3HLT
225 #define EL3HLT          (ERROR_BASE_NO + 46)
226 #endif
227 
228 #ifndef EL3RST
229 #define EL3RST          (ERROR_BASE_NO + 47)
230 #endif
231 
232 #ifndef ELNRNG
233 #define ELNRNG          (ERROR_BASE_NO + 48)
234 #endif
235 
236 #ifndef EUNATCH
237 #define EUNATCH         (ERROR_BASE_NO + 49)
238 #endif
239 
240 #ifndef ENOCSI
241 #define ENOCSI          (ERROR_BASE_NO + 50)
242 #endif
243 
244 #ifndef EL2HLT
245 #define EL2HLT          (ERROR_BASE_NO + 51)
246 #endif
247 
248 #ifndef EBADE
249 #define EBADE           (ERROR_BASE_NO + 52)
250 #endif
251 
252 #ifndef EBADR
253 #define EBADR           (ERROR_BASE_NO + 53)
254 #endif
255 
256 #ifndef EXFULL
257 #define EXFULL          (ERROR_BASE_NO + 54)
258 #endif
259 
260 #ifndef ENOANO
261 #define ENOANO          (ERROR_BASE_NO + 55)
262 #endif
263 
264 #ifndef EBADRQC
265 #define EBADRQC         (ERROR_BASE_NO + 56)
266 #endif
267 
268 #ifndef EBADSLT
269 #define EBADSLT         (ERROR_BASE_NO + 57)
270 #endif
271 
272 #ifndef EDEADLOCK
273 #define EDEADLOCK       EDEADLK
274 #endif
275 
276 #ifndef EBFONT
277 #define EBFONT          (ERROR_BASE_NO + 59)
278 #endif
279 
280 #ifndef ENOSTR
281 #define ENOSTR          (ERROR_BASE_NO + 60)
282 #endif
283 
284 #ifndef ENODATA
285 #define ENODATA         (ERROR_BASE_NO + 61)
286 #endif
287 
288 #ifndef ETIME
289 #define ETIME           (ERROR_BASE_NO + 62)
290 #endif
291 
292 #ifndef ENOSR
293 #define ENOSR           (ERROR_BASE_NO + 63)
294 #endif
295 
296 #ifndef ENONET
297 #define ENONET          (ERROR_BASE_NO + 64)
298 #endif
299 
300 #ifndef ENOPKG
301 #define ENOPKG          (ERROR_BASE_NO + 65)
302 #endif
303 
304 #ifndef EREMOTE
305 #define EREMOTE         (ERROR_BASE_NO + 66)
306 #endif
307 
308 #ifndef ENOLINK
309 #define ENOLINK         (ERROR_BASE_NO + 67)
310 #endif
311 
312 #ifndef EADV
313 #define EADV            (ERROR_BASE_NO + 68)
314 #endif
315 
316 #ifndef ESRMNT
317 #define ESRMNT          (ERROR_BASE_NO + 69)
318 #endif
319 
320 #ifndef ECOMM
321 #define ECOMM           (ERROR_BASE_NO + 70)
322 #endif
323 
324 #ifndef EPROTO
325 #define EPROTO          (ERROR_BASE_NO + 71)
326 #endif
327 
328 #ifndef EMULTIHOP
329 #define EMULTIHOP       (ERROR_BASE_NO + 72)
330 #endif
331 
332 #ifndef EDOTDOT
333 #define EDOTDOT         (ERROR_BASE_NO + 73)
334 #endif
335 
336 #ifndef EBADMSG
337 #define EBADMSG         (ERROR_BASE_NO + 74)
338 #endif
339 
340 #ifndef EOVERFLOW
341 #define EOVERFLOW       (ERROR_BASE_NO + 75)
342 #endif
343 
344 #ifndef ENOTUNIQ
345 #define ENOTUNIQ        (ERROR_BASE_NO + 76)
346 #endif
347 
348 #ifndef EBADFD
349 #define EBADFD          (ERROR_BASE_NO + 77)
350 #endif
351 
352 #ifndef EREMCHG
353 #define EREMCHG         (ERROR_BASE_NO + 78)
354 #endif
355 
356 #ifndef ELIBACC
357 #define ELIBACC         (ERROR_BASE_NO + 79)
358 #endif
359 
360 #ifndef ELIBBAD
361 #define ELIBBAD         (ERROR_BASE_NO + 80)
362 #endif
363 
364 #ifndef ELIBSCN
365 #define ELIBSCN         (ERROR_BASE_NO + 81)
366 #endif
367 
368 #ifndef ELIBMAX
369 #define ELIBMAX         (ERROR_BASE_NO + 82)
370 #endif
371 
372 #ifndef ELIBEXEC
373 #define ELIBEXEC        (ERROR_BASE_NO + 83)
374 #endif
375 
376 #ifndef EILSEQ
377 #define EILSEQ          (ERROR_BASE_NO + 84)
378 #endif
379 
380 #ifndef ERESTART
381 #define ERESTART        (ERROR_BASE_NO + 85)
382 #endif
383 
384 #ifndef ESTRPIPE
385 #define ESTRPIPE        (ERROR_BASE_NO + 86)
386 #endif
387 
388 #ifndef EUSERS
389 #define EUSERS          (ERROR_BASE_NO + 87)
390 #endif
391 
392 #ifndef ENOTSOCK
393 #define ENOTSOCK        (ERROR_BASE_NO + 88)
394 #endif
395 
396 #ifndef EDESTADDRREQ
397 #define EDESTADDRREQ    (ERROR_BASE_NO + 89)
398 #endif
399 
400 #ifndef EMSGSIZE
401 #define EMSGSIZE        (ERROR_BASE_NO + 90)
402 #endif
403 
404 #ifndef EPROTOTYPE
405 #define EPROTOTYPE      (ERROR_BASE_NO + 91)
406 #endif
407 
408 #ifndef ENOPROTOOPT
409 #define ENOPROTOOPT     (ERROR_BASE_NO + 92)
410 #endif
411 
412 #ifndef EPROTONOSUPPORT
413 #define EPROTONOSUPPORT (ERROR_BASE_NO + 93)
414 #endif
415 
416 #ifndef ESOCKTNOSUPPORT
417 #define ESOCKTNOSUPPORT (ERROR_BASE_NO + 94)
418 #endif
419 
420 #ifndef EOPNOTSUPP
421 #define EOPNOTSUPP      (ERROR_BASE_NO + 95)
422 #endif
423 
424 #ifndef ENOTSUP
425 #define ENOTSUP         EOPNOTSUPP
426 #endif
427 
428 #ifndef EPFNOSUPPORT
429 #define EPFNOSUPPORT    (ERROR_BASE_NO + 96)
430 #endif
431 
432 #ifndef EAFNOSUPPORT
433 #define EAFNOSUPPORT    (ERROR_BASE_NO + 97)
434 #endif
435 
436 #ifndef EADDRINUSE
437 #define EADDRINUSE      (ERROR_BASE_NO + 98)
438 #endif
439 
440 #ifndef EADDRNOTAVAIL
441 #define EADDRNOTAVAIL   (ERROR_BASE_NO + 99)
442 #endif
443 
444 #ifndef ENETDOWN
445 #define ENETDOWN        (ERROR_BASE_NO + 100)
446 #endif
447 
448 #ifndef ENETUNREACH
449 #define ENETUNREACH     (ERROR_BASE_NO + 101)
450 #endif
451 
452 #ifndef ENETRESET
453 #define ENETRESET       (ERROR_BASE_NO + 102)
454 #endif
455 
456 #ifndef ECONNABORTED
457 #define ECONNABORTED    (ERROR_BASE_NO + 103)
458 #endif
459 
460 #ifndef ECONNRESET
461 #define ECONNRESET      (ERROR_BASE_NO + 104)
462 #endif
463 
464 #ifndef ENOBUFS
465 #define ENOBUFS         (ERROR_BASE_NO + 105)
466 #endif
467 
468 #ifndef EISCONN
469 #define EISCONN         (ERROR_BASE_NO + 106)
470 #endif
471 
472 #ifndef ENOTCONN
473 #define ENOTCONN        (ERROR_BASE_NO + 107)
474 #endif
475 
476 #ifndef ESHUTDOWN
477 #define ESHUTDOWN       (ERROR_BASE_NO + 108)
478 #endif
479 
480 #ifndef ETOOMANYREFS
481 #define ETOOMANYREFS    (ERROR_BASE_NO + 109)
482 #endif
483 
484 #ifndef ETIMEDOUT
485 #define ETIMEDOUT       (ERROR_BASE_NO + 110)
486 #endif
487 
488 #ifndef ECONNREFUSED
489 #define ECONNREFUSED    (ERROR_BASE_NO + 111)
490 #endif
491 
492 #ifndef EHOSTDOWN
493 #define EHOSTDOWN       (ERROR_BASE_NO + 112)
494 #endif
495 
496 #ifndef EHOSTUNREACH
497 #define EHOSTUNREACH    (ERROR_BASE_NO + 113)
498 #endif
499 
500 #ifndef EALREADY
501 #define EALREADY        (ERROR_BASE_NO + 114)
502 #endif
503 
504 #ifndef EINPROGRESS
505 #define EINPROGRESS     (ERROR_BASE_NO + 115)
506 #endif
507 
508 #ifndef ESTALE
509 #define ESTALE          (ERROR_BASE_NO + 116)
510 #endif
511 
512 #ifndef EUCLEAN
513 #define EUCLEAN         (ERROR_BASE_NO + 117)
514 #endif
515 
516 #ifndef ENOTNAM
517 #define ENOTNAM         (ERROR_BASE_NO + 118)
518 #endif
519 
520 #ifndef ENAVAIL
521 #define ENAVAIL         (ERROR_BASE_NO + 119)
522 #endif
523 
524 #ifndef EISNAM
525 #define EISNAM          (ERROR_BASE_NO + 120)
526 #endif
527 
528 #ifndef EREMOTEIO
529 #define EREMOTEIO       (ERROR_BASE_NO + 121)
530 #endif
531 
532 #ifndef EDQUOT
533 #define EDQUOT          (ERROR_BASE_NO + 122)
534 #endif
535 
536 #ifndef ENOMEDIUM
537 #define ENOMEDIUM       (ERROR_BASE_NO + 123)
538 #endif
539 
540 #ifndef EMEDIUMTYPE
541 #define EMEDIUMTYPE     (ERROR_BASE_NO + 124)
542 #endif
543 
544 #ifndef ECANCELED
545 #define ECANCELED       (ERROR_BASE_NO + 125)
546 #endif
547 
548 #ifndef ENOKEY
549 #define ENOKEY          (ERROR_BASE_NO + 126)
550 #endif
551 
552 #ifndef EKEYEXPIRED
553 #define EKEYEXPIRED     (ERROR_BASE_NO + 127)
554 #endif
555 
556 #ifndef EKEYREVOKED
557 #define EKEYREVOKED     (ERROR_BASE_NO + 128)
558 #endif
559 
560 #ifndef EKEYREJECTED
561 #define EKEYREJECTED    (ERROR_BASE_NO + 129)
562 #endif
563 
564 #ifndef EOWNERDEAD
565 #define EOWNERDEAD      (ERROR_BASE_NO + 130)
566 #endif
567 
568 #ifndef ENOTRECOVERABLE
569 #define ENOTRECOVERABLE (ERROR_BASE_NO + 131)
570 #endif
571 
572 #ifndef ERFKILL
573 #define ERFKILL         (ERROR_BASE_NO + 132)
574 #endif
575 
576 #ifndef EHWPOISON
577 #define EHWPOISON       (ERROR_BASE_NO + 133)
578 #endif
579 
580 #elif defined(_WIN32)
581 #include <errno.h>
582 
583 #endif /* defined(__ARMCC_VERSION) || defined(__IAR_SYSTEMS_ICC__) */
584 
585 #endif /* __SYS_ERRNO_H__ */
586