mperrno.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. #include "py/mpconfig.h"
  29. #if MICROPY_USE_INTERNAL_ERRNO
  30. // MP_Exxx errno's are defined directly as numeric values
  31. // (Linux constants are used as a reference)
  32. #define MP_EPERM (1) // Operation not permitted
  33. #define MP_ENOENT (2) // No such file or directory
  34. #define MP_ESRCH (3) // No such process
  35. #define MP_EINTR (4) // Interrupted system call
  36. #define MP_EIO (5) // I/O error
  37. #define MP_ENXIO (6) // No such device or address
  38. #define MP_E2BIG (7) // Argument list too long
  39. #define MP_ENOEXEC (8) // Exec format error
  40. #define MP_EBADF (9) // Bad file number
  41. #define MP_ECHILD (10) // No child processes
  42. #define MP_EAGAIN (11) // Try again
  43. #define MP_ENOMEM (12) // Out of memory
  44. #define MP_EACCES (13) // Permission denied
  45. #define MP_EFAULT (14) // Bad address
  46. #define MP_ENOTBLK (15) // Block device required
  47. #define MP_EBUSY (16) // Device or resource busy
  48. #define MP_EEXIST (17) // File exists
  49. #define MP_EXDEV (18) // Cross-device link
  50. #define MP_ENODEV (19) // No such device
  51. #define MP_ENOTDIR (20) // Not a directory
  52. #define MP_EISDIR (21) // Is a directory
  53. #define MP_EINVAL (22) // Invalid argument
  54. #define MP_ENFILE (23) // File table overflow
  55. #define MP_EMFILE (24) // Too many open files
  56. #define MP_ENOTTY (25) // Not a typewriter
  57. #define MP_ETXTBSY (26) // Text file busy
  58. #define MP_EFBIG (27) // File too large
  59. #define MP_ENOSPC (28) // No space left on device
  60. #define MP_ESPIPE (29) // Illegal seek
  61. #define MP_EROFS (30) // Read-only file system
  62. #define MP_EMLINK (31) // Too many links
  63. #define MP_EPIPE (32) // Broken pipe
  64. #define MP_EDOM (33) // Math argument out of domain of func
  65. #define MP_ERANGE (34) // Math result not representable
  66. #define MP_EWOULDBLOCK MP_EAGAIN // Operation would block
  67. #define MP_EOPNOTSUPP (95) // Operation not supported on transport endpoint
  68. #define MP_EAFNOSUPPORT (97) // Address family not supported by protocol
  69. #define MP_EADDRINUSE (98) // Address already in use
  70. #define MP_ECONNABORTED (103) // Software caused connection abort
  71. #define MP_ECONNRESET (104) // Connection reset by peer
  72. #define MP_ENOBUFS (105) // No buffer space available
  73. #define MP_EISCONN (106) // Transport endpoint is already connected
  74. #define MP_ENOTCONN (107) // Transport endpoint is not connected
  75. #define MP_ETIMEDOUT (110) // Connection timed out
  76. #define MP_ECONNREFUSED (111) // Connection refused
  77. #define MP_EHOSTUNREACH (113) // No route to host
  78. #define MP_EALREADY (114) // Operation already in progress
  79. #define MP_EINPROGRESS (115) // Operation now in progress
  80. #define MP_ECANCELED (125) // Operation canceled
  81. #else
  82. // MP_Exxx errno's are defined in terms of system supplied ones
  83. #include <errno.h>
  84. #define MP_EPERM EPERM
  85. #define MP_ENOENT ENOENT
  86. #define MP_ESRCH ESRCH
  87. #define MP_EINTR EINTR
  88. #define MP_EIO EIO
  89. #define MP_ENXIO ENXIO
  90. #define MP_E2BIG E2BIG
  91. #define MP_ENOEXEC ENOEXEC
  92. #define MP_EBADF EBADF
  93. #define MP_ECHILD ECHILD
  94. #define MP_EAGAIN EAGAIN
  95. #define MP_ENOMEM ENOMEM
  96. #define MP_EACCES EACCES
  97. #define MP_EFAULT EFAULT
  98. #define MP_ENOTBLK ENOTBLK
  99. #define MP_EBUSY EBUSY
  100. #define MP_EEXIST EEXIST
  101. #define MP_EXDEV EXDEV
  102. #define MP_ENODEV ENODEV
  103. #define MP_ENOTDIR ENOTDIR
  104. #define MP_EISDIR EISDIR
  105. #define MP_EINVAL EINVAL
  106. #define MP_ENFILE ENFILE
  107. #define MP_EMFILE EMFILE
  108. #define MP_ENOTTY ENOTTY
  109. #define MP_ETXTBSY ETXTBSY
  110. #define MP_EFBIG EFBIG
  111. #define MP_ENOSPC ENOSPC
  112. #define MP_ESPIPE ESPIPE
  113. #define MP_EROFS EROFS
  114. #define MP_EMLINK EMLINK
  115. #define MP_EPIPE EPIPE
  116. #define MP_EDOM EDOM
  117. #define MP_ERANGE ERANGE
  118. #define MP_EWOULDBLOCK EWOULDBLOCK
  119. #define MP_EOPNOTSUPP EOPNOTSUPP
  120. #define MP_EAFNOSUPPORT EAFNOSUPPORT
  121. #define MP_EADDRINUSE EADDRINUSE
  122. #define MP_ECONNABORTED ECONNABORTED
  123. #define MP_ECONNRESET ECONNRESET
  124. #define MP_ENOBUFS ENOBUFS
  125. #define MP_EISCONN EISCONN
  126. #define MP_ENOTCONN ENOTCONN
  127. #define MP_ETIMEDOUT ETIMEDOUT
  128. #define MP_ECONNREFUSED ECONNREFUSED
  129. #define MP_EHOSTUNREACH EHOSTUNREACH
  130. #define MP_EALREADY EALREADY
  131. #define MP_EINPROGRESS EINPROGRESS
  132. #define MP_ECANCELED ECANCELED
  133. #endif
  134. #if MICROPY_PY_ERRNO
  135. #include "py/obj.h"
  136. qstr mp_errno_to_str(mp_obj_t errno_val);
  137. #endif
  138. #endif // MICROPY_INCLUDED_PY_MPERRNO_H