1 /*
2  * This file is part of the MicroPython project, http://micropython.org/
3  *
4  * The MIT License (MIT)
5  *
6  * Copyright (c) 2016 Damien P. George
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  */
26 #ifndef MICROPY_INCLUDED_PY_MPERRNO_H
27 #define MICROPY_INCLUDED_PY_MPERRNO_H
28 
29 #include "py/mpconfig.h"
30 
31 #if MICROPY_USE_INTERNAL_ERRNO
32 
33 // Modified bt HaaS begin
34 #include <errno.h>
35 // Modified bt HaaS end
36 
37 // MP_Exxx errno's are defined directly as numeric values
38 // (Linux constants are used as a reference)
39 
40 #define MP_EPERM              (1) // Operation not permitted
41 #define MP_ENOENT             (2) // No such file or directory
42 #define MP_ESRCH              (3) // No such process
43 #define MP_EINTR              (4) // Interrupted system call
44 #define MP_EIO                (5) // I/O error
45 #define MP_ENXIO              (6) // No such device or address
46 #define MP_E2BIG              (7) // Argument list too long
47 #define MP_ENOEXEC            (8) // Exec format error
48 #define MP_EBADF              (9) // Bad file number
49 #define MP_ECHILD            (10) // No child processes
50 #define MP_EAGAIN            (11) // Try again
51 #define MP_ENOMEM            (12) // Out of memory
52 #define MP_EACCES            (13) // Permission denied
53 #define MP_EFAULT            (14) // Bad address
54 #define MP_ENOTBLK           (15) // Block device required
55 #define MP_EBUSY             (16) // Device or resource busy
56 #define MP_EEXIST            (17) // File exists
57 #define MP_EXDEV             (18) // Cross-device link
58 #define MP_ENODEV            (19) // No such device
59 #define MP_ENOTDIR           (20) // Not a directory
60 #define MP_EISDIR            (21) // Is a directory
61 #define MP_EINVAL            (22) // Invalid argument
62 #define MP_ENFILE            (23) // File table overflow
63 #define MP_EMFILE            (24) // Too many open files
64 #define MP_ENOTTY            (25) // Not a typewriter
65 #define MP_ETXTBSY           (26) // Text file busy
66 #define MP_EFBIG             (27) // File too large
67 #define MP_ENOSPC            (28) // No space left on device
68 #define MP_ESPIPE            (29) // Illegal seek
69 #define MP_EROFS             (30) // Read-only file system
70 #define MP_EMLINK            (31) // Too many links
71 #define MP_EPIPE             (32) // Broken pipe
72 #define MP_EDOM              (33) // Math argument out of domain of func
73 #define MP_ERANGE            (34) // Math result not representable
74 #define MP_EWOULDBLOCK  MP_EAGAIN // Operation would block
75 #define MP_EOPNOTSUPP        (95) // Operation not supported on transport endpoint
76 #define MP_EAFNOSUPPORT      (97) // Address family not supported by protocol
77 #define MP_EADDRINUSE        (98) // Address already in use
78 #define MP_ECONNABORTED     (103) // Software caused connection abort
79 #define MP_ECONNRESET       (104) // Connection reset by peer
80 #define MP_ENOBUFS          (105) // No buffer space available
81 #define MP_EISCONN          (106) // Transport endpoint is already connected
82 #define MP_ENOTCONN         (107) // Transport endpoint is not connected
83 #define MP_ETIMEDOUT        (110) // Connection timed out
84 #define MP_ECONNREFUSED     (111) // Connection refused
85 #define MP_EHOSTUNREACH     (113) // No route to host
86 #define MP_EALREADY         (114) // Operation already in progress
87 #define MP_EINPROGRESS      (115) // Operation now in progress
88 #define MP_ECANCELED        (125) // Operation canceled
89 
90 #else
91 
92 // MP_Exxx errno's are defined in terms of system supplied ones
93 
94 #include <errno.h>
95 
96 #define MP_EPERM            EPERM
97 #define MP_ENOENT           ENOENT
98 #define MP_ESRCH            ESRCH
99 #define MP_EINTR            EINTR
100 #define MP_EIO              EIO
101 #define MP_ENXIO            ENXIO
102 #define MP_E2BIG            E2BIG
103 #define MP_ENOEXEC          ENOEXEC
104 #define MP_EBADF            EBADF
105 #define MP_ECHILD           ECHILD
106 #define MP_EAGAIN           EAGAIN
107 #define MP_ENOMEM           ENOMEM
108 #define MP_EACCES           EACCES
109 #define MP_EFAULT           EFAULT
110 #define MP_ENOTBLK          ENOTBLK
111 #define MP_EBUSY            EBUSY
112 #define MP_EEXIST           EEXIST
113 #define MP_EXDEV            EXDEV
114 #define MP_ENODEV           ENODEV
115 #define MP_ENOTDIR          ENOTDIR
116 #define MP_EISDIR           EISDIR
117 #define MP_EINVAL           EINVAL
118 #define MP_ENFILE           ENFILE
119 #define MP_EMFILE           EMFILE
120 #define MP_ENOTTY           ENOTTY
121 #define MP_ETXTBSY          ETXTBSY
122 #define MP_EFBIG            EFBIG
123 #define MP_ENOSPC           ENOSPC
124 #define MP_ESPIPE           ESPIPE
125 #define MP_EROFS            EROFS
126 #define MP_EMLINK           EMLINK
127 #define MP_EPIPE            EPIPE
128 #define MP_EDOM             EDOM
129 #define MP_ERANGE           ERANGE
130 #define MP_EWOULDBLOCK      EWOULDBLOCK
131 #define MP_EOPNOTSUPP       EOPNOTSUPP
132 #define MP_EAFNOSUPPORT     EAFNOSUPPORT
133 #define MP_EADDRINUSE       EADDRINUSE
134 #define MP_ECONNABORTED     ECONNABORTED
135 #define MP_ECONNRESET       ECONNRESET
136 #define MP_ENOBUFS          ENOBUFS
137 #define MP_EISCONN          EISCONN
138 #define MP_ENOTCONN         ENOTCONN
139 #define MP_ETIMEDOUT        ETIMEDOUT
140 #define MP_ECONNREFUSED     ECONNREFUSED
141 #define MP_EHOSTUNREACH     EHOSTUNREACH
142 #define MP_EALREADY         EALREADY
143 #define MP_EINPROGRESS      EINPROGRESS
144 #define MP_ECANCELED        ECANCELED
145 
146 #endif
147 
148 #if MICROPY_PY_UERRNO
149 
150 #include "py/obj.h"
151 
152 qstr mp_errno_to_str(mp_obj_t errno_val);
153 
154 #endif
155 
156 #endif // MICROPY_INCLUDED_PY_MPERRNO_H
157