/uspace/lib/posix/include/posix/errno.h

https://gitlab.com/vhelen/vhelen · C Header · 326 lines · 254 code · 13 blank · 59 comment · 0 complexity · 80a97948974c34016cc1c963432a99e9 MD5 · raw file

  1. /*
  2. * Copyright (c) 2011 Jiri Zarevucky
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * - Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * - Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * - The name of the author may not be used to endorse or promote products
  15. * derived from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. /** @addtogroup libposix
  29. * @{
  30. */
  31. /** @file System error numbers.
  32. */
  33. #ifndef POSIX_ERRNO_H_
  34. #define POSIX_ERRNO_H_
  35. #include "libc/errno.h"
  36. /* IMPORTANT:
  37. * Since libc uses negative errorcodes, some sort of conversion is necessary to
  38. * keep POSIX programs and libraries from breaking. This file maps POSIX error
  39. * codes to absolute values of corresponding libc codes where available, and
  40. * assigns new code where there is no prior definition in libc.
  41. *
  42. * A new errno variable is defined. When accessed, the function first looks at
  43. * libc errno and iff it is != 0, sets the POSIX errno to absolute value of
  44. * libc errno. Given that no library function sets errno to 0 and that all
  45. * POSIX libraries will be used solely by POSIX programs (thus, there only needs
  46. * to be one way correspondence between errno and posix_errno), this approach
  47. * should work as expected in most cases and does not require any wrappers for
  48. * libc routines that would just change errno values.
  49. *
  50. * There is no conditioning by LIBPOSIX_INTERNAL for redefinitions of macros.
  51. * If there is a need to check errno for a value not defined by POSIX, it's
  52. * necessary to compare errno against abs(ECODE), because there is no
  53. * redefinition for such error codes.
  54. *
  55. * XXX: maybe all HOS error codes should be redefined
  56. *
  57. * NOTE: This redefinition is slightly POSIX incompatible, since the
  58. * specification requires the macro values to be usable in preprocessing
  59. * directives. I don't think that's very important, though.
  60. */
  61. #undef errno
  62. #define errno (*__posix_errno())
  63. extern int *__posix_errno(void);
  64. #define __TOP_ERRNO (-NO_DATA)
  65. enum {
  66. POSIX_E2BIG = __TOP_ERRNO + 1,
  67. POSIX_EACCES = __TOP_ERRNO + 2,
  68. POSIX_EADDRINUSE = -EADDRINUSE,
  69. POSIX_EADDRNOTAVAIL = -EADDRNOTAVAIL,
  70. POSIX_EAFNOSUPPORT = -EAFNOSUPPORT,
  71. POSIX_EAGAIN = -EAGAIN,
  72. POSIX_EALREADY = __TOP_ERRNO + 3,
  73. POSIX_EBADF = -EBADF,
  74. POSIX_EBADMSG = __TOP_ERRNO + 4,
  75. POSIX_EBUSY = -EBUSY,
  76. POSIX_ECANCELED = __TOP_ERRNO + 5,
  77. POSIX_ECHILD = __TOP_ERRNO + 6,
  78. POSIX_ECONNABORTED = __TOP_ERRNO + 7,
  79. POSIX_ECONNREFUSED = __TOP_ERRNO + 8,
  80. POSIX_ECONNRESET = __TOP_ERRNO + 9,
  81. POSIX_EDEADLK = __TOP_ERRNO + 10,
  82. POSIX_EDESTADDRREQ = -EDESTADDRREQ,
  83. POSIX_EDOM = __TOP_ERRNO + 11,
  84. POSIX_EDQUOT = __TOP_ERRNO + 12,
  85. POSIX_EEXIST = -EEXIST,
  86. POSIX_EFAULT = __TOP_ERRNO + 13,
  87. POSIX_EFBIG = __TOP_ERRNO + 14,
  88. POSIX_EHOSTUNREACH = __TOP_ERRNO + 15,
  89. POSIX_EIDRM = __TOP_ERRNO + 16,
  90. POSIX_EILSEQ = __TOP_ERRNO + 17,
  91. POSIX_EINPROGRESS = -EINPROGRESS,
  92. POSIX_EINTR = -EINTR,
  93. POSIX_EINVAL = -EINVAL,
  94. POSIX_EIO = -EIO,
  95. POSIX_EISCONN = __TOP_ERRNO + 18,
  96. POSIX_EISDIR = -EISDIR,
  97. POSIX_ELOOP = __TOP_ERRNO + 19,
  98. POSIX_EMFILE = -EMFILE,
  99. POSIX_EMLINK = -EMLINK,
  100. POSIX_EMSGSIZE = __TOP_ERRNO + 20,
  101. POSIX_EMULTIHOP = __TOP_ERRNO + 21,
  102. POSIX_ENAMETOOLONG = -ENAMETOOLONG,
  103. POSIX_ENETDOWN = __TOP_ERRNO + 22,
  104. POSIX_ENETRESET = __TOP_ERRNO + 23,
  105. POSIX_ENETUNREACH = __TOP_ERRNO + 24,
  106. POSIX_ENFILE = __TOP_ERRNO + 25,
  107. POSIX_ENOBUFS = __TOP_ERRNO + 26,
  108. POSIX_ENODATA = -NO_DATA,
  109. POSIX_ENODEV = __TOP_ERRNO + 27,
  110. POSIX_ENOENT = -ENOENT,
  111. POSIX_ENOEXEC = __TOP_ERRNO + 28,
  112. POSIX_ENOLCK = __TOP_ERRNO + 29,
  113. POSIX_ENOLINK = __TOP_ERRNO + 30,
  114. POSIX_ENOMEM = -ENOMEM,
  115. POSIX_ENOMSG = __TOP_ERRNO + 31,
  116. POSIX_ENOPROTOOPT = __TOP_ERRNO + 32,
  117. POSIX_ENOSPC = -ENOSPC,
  118. POSIX_ENOSR = __TOP_ERRNO + 33,
  119. POSIX_ENOSTR = __TOP_ERRNO + 34,
  120. POSIX_ENOSYS = __TOP_ERRNO + 35,
  121. POSIX_ENOTCONN = -ENOTCONN,
  122. POSIX_ENOTDIR = -ENOTDIR,
  123. POSIX_ENOTEMPTY = -ENOTEMPTY,
  124. POSIX_ENOTRECOVERABLE = __TOP_ERRNO + 36,
  125. POSIX_ENOTSOCK = -ENOTSOCK,
  126. POSIX_ENOTSUP = -ENOTSUP,
  127. POSIX_ENOTTY = __TOP_ERRNO + 37,
  128. POSIX_ENXIO = __TOP_ERRNO + 38,
  129. POSIX_EOPNOTSUPP = __TOP_ERRNO + 39,
  130. POSIX_EOVERFLOW = -EOVERFLOW,
  131. POSIX_EOWNERDEAD = __TOP_ERRNO + 40,
  132. POSIX_EPERM = -EPERM,
  133. POSIX_EPIPE = __TOP_ERRNO + 41,
  134. POSIX_EPROTO = __TOP_ERRNO + 42,
  135. POSIX_EPROTONOSUPPORT = -EPROTONOSUPPORT,
  136. POSIX_EPROTOTYPE = __TOP_ERRNO + 43,
  137. POSIX_ERANGE = -ERANGE,
  138. POSIX_EROFS = __TOP_ERRNO + 44,
  139. POSIX_ESPIPE = __TOP_ERRNO + 45,
  140. POSIX_ESRCH = __TOP_ERRNO + 46,
  141. POSIX_ESTALE = __TOP_ERRNO + 47,
  142. POSIX_ETIME = __TOP_ERRNO + 48,
  143. POSIX_ETIMEDOUT = __TOP_ERRNO + 49,
  144. POSIX_ETXTBSY = __TOP_ERRNO + 50,
  145. POSIX_EWOULDBLOCK = __TOP_ERRNO + 51,
  146. POSIX_EXDEV = -EXDEV,
  147. };
  148. #undef __TOP_ERRNO
  149. #undef E2BIG
  150. #undef EACCES
  151. #undef EADDRINUSE
  152. #undef EADDRNOTAVAIL
  153. #undef EAFNOSUPPORT
  154. #undef EAGAIN
  155. #undef EALREADY
  156. #undef EBADF
  157. #undef EBADMSG
  158. #undef EBUSY
  159. #undef ECANCELED
  160. #undef ECHILD
  161. #undef ECONNABORTED
  162. #undef ECONNREFUSED
  163. #undef ECONNRESET
  164. #undef EDEADLK
  165. #undef EDESTADDRREQ
  166. #undef EDOM
  167. #undef EDQUOT
  168. #undef EEXIST
  169. #undef EFAULT
  170. #undef EFBIG
  171. #undef EHOSTUNREACH
  172. #undef EIDRM
  173. #undef EILSEQ
  174. #undef EINPROGRESS
  175. #undef EINTR
  176. #undef EINVAL
  177. #undef EIO
  178. #undef EISCONN
  179. #undef EISDIR
  180. #undef ELOOP
  181. #undef EMFILE
  182. #undef EMLINK
  183. #undef EMSGSIZE
  184. #undef EMULTIHOP
  185. #undef ENAMETOOLONG
  186. #undef ENETDOWN
  187. #undef ENETRESET
  188. #undef ENETUNREACH
  189. #undef ENFILE
  190. #undef ENOBUFS
  191. #undef ENODATA
  192. #undef ENODEV
  193. #undef ENOENT
  194. #undef ENOEXEC
  195. #undef ENOLCK
  196. #undef ENOLINK
  197. #undef ENOMEM
  198. #undef ENOMSG
  199. #undef ENOPROTOOPT
  200. #undef ENOSPC
  201. #undef ENOSR
  202. #undef ENOSTR
  203. #undef ENOSYS
  204. #undef ENOTCONN
  205. #undef ENOTDIR
  206. #undef ENOTEMPTY
  207. #undef ENOTRECOVERABLE
  208. #undef ENOTSOCK
  209. #undef ENOTSUP
  210. #undef ENOTTY
  211. #undef ENXIO
  212. #undef EOPNOTSUPP
  213. #undef EOVERFLOW
  214. #undef EOWNERDEAD
  215. #undef EPERM
  216. #undef EPIPE
  217. #undef EPROTO
  218. #undef EPROTONOSUPPORT
  219. #undef EPROTOTYPE
  220. #undef ERANGE
  221. #undef EROFS
  222. #undef ESPIPE
  223. #undef ESRCH
  224. #undef ESTALE
  225. #undef ETIME
  226. #undef ETIMEDOUT
  227. #undef ETXTBSY
  228. #undef EWOULDBLOCK
  229. #undef EXDEV
  230. #define E2BIG POSIX_E2BIG
  231. #define EACCES POSIX_EACCES
  232. #define EADDRINUSE POSIX_EADDRINUSE
  233. #define EADDRNOTAVAIL POSIX_EADDRNOTAVAIL
  234. #define EAFNOSUPPORT POSIX_EAFNOSUPPORT
  235. #define EAGAIN POSIX_EAGAIN
  236. #define EALREADY POSIX_EALREADY
  237. #define EBADF POSIX_EBADF
  238. #define EBADMSG POSIX_EBADMSG
  239. #define EBUSY POSIX_EBUSY
  240. #define ECANCELED POSIX_ECANCELED
  241. #define ECHILD POSIX_ECHILD
  242. #define ECONNABORTED POSIX_ECONNABORTED
  243. #define ECONNREFUSED POSIX_ECONNREFUSED
  244. #define ECONNRESET POSIX_ECONNRESET
  245. #define EDEADLK POSIX_EDEADLK
  246. #define EDESTADDRREQ POSIX_EDESTADDRREQ
  247. #define EDOM POSIX_EDOM
  248. #define EDQUOT POSIX_EDQUOT
  249. #define EEXIST POSIX_EEXIST
  250. #define EFAULT POSIX_EFAULT
  251. #define EFBIG POSIX_EFBIG
  252. #define EHOSTUNREACH POSIX_EHOSTUNREACH
  253. #define EIDRM POSIX_EIDRM
  254. #define EILSEQ POSIX_EILSEQ
  255. #define EINPROGRESS POSIX_EINPROGRESS
  256. #define EINTR POSIX_EINTR
  257. #define EINVAL POSIX_EINVAL
  258. #define EIO POSIX_EIO
  259. #define EISCONN POSIX_EISCONN
  260. #define EISDIR POSIX_EISDIR
  261. #define ELOOP POSIX_ELOOP
  262. #define EMFILE POSIX_EMFILE
  263. #define EMLINK POSIX_EMLINK
  264. #define EMSGSIZE POSIX_EMSGSIZE
  265. #define EMULTIHOP POSIX_EMULTIHOP
  266. #define ENAMETOOLONG POSIX_ENAMETOOLONG
  267. #define ENETDOWN POSIX_ENETDOWN
  268. #define ENETRESET POSIX_ENETRESET
  269. #define ENETUNREACH POSIX_ENETUNREACH
  270. #define ENFILE POSIX_ENFILE
  271. #define ENOBUFS POSIX_ENOBUFS
  272. #define ENODATA POSIX_ENODATA
  273. #define ENODEV POSIX_ENODEV
  274. #define ENOENT POSIX_ENOENT
  275. #define ENOEXEC POSIX_ENOEXEC
  276. #define ENOLCK POSIX_ENOLCK
  277. #define ENOLINK POSIX_ENOLINK
  278. #define ENOMEM POSIX_ENOMEM
  279. #define ENOMSG POSIX_ENOMSG
  280. #define ENOPROTOOPT POSIX_ENOPROTOOPT
  281. #define ENOSPC POSIX_ENOSPC
  282. #define ENOSR POSIX_ENOSR
  283. #define ENOSTR POSIX_ENOSTR
  284. #define ENOSYS POSIX_ENOSYS
  285. #define ENOTCONN POSIX_ENOTCONN
  286. #define ENOTDIR POSIX_ENOTDIR
  287. #define ENOTEMPTY POSIX_ENOTEMPTY
  288. #define ENOTRECOVERABLE POSIX_ENOTRECOVERABLE
  289. #define ENOTSOCK POSIX_ENOTSOCK
  290. #define ENOTSUP POSIX_ENOTSUP
  291. #define ENOTTY POSIX_ENOTTY
  292. #define ENXIO POSIX_ENXIO
  293. #define EOPNOTSUPP POSIX_EOPNOTSUPP
  294. #define EOVERFLOW POSIX_EOVERFLOW
  295. #define EOWNERDEAD POSIX_EOWNERDEAD
  296. #define EPERM POSIX_EPERM
  297. #define EPIPE POSIX_EPIPE
  298. #define EPROTO POSIX_EPROTO
  299. #define EPROTONOSUPPORT POSIX_EPROTONOSUPPORT
  300. #define EPROTOTYPE POSIX_EPROTOTYPE
  301. #define ERANGE POSIX_ERANGE
  302. #define EROFS POSIX_EROFS
  303. #define ESPIPE POSIX_ESPIPE
  304. #define ESRCH POSIX_ESRCH
  305. #define ESTALE POSIX_ESTALE
  306. #define ETIME POSIX_ETIME
  307. #define ETIMEDOUT POSIX_ETIMEDOUT
  308. #define ETXTBSY POSIX_ETXTBSY
  309. #define EWOULDBLOCK POSIX_EWOULDBLOCK
  310. #define EXDEV POSIX_EXDEV
  311. #endif /* POSIX_ERRNO_H_ */
  312. /** @}
  313. */