errorno.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. /* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to
  5. * deal in the Software without restriction, including without limitation the
  6. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  7. * sell copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  18. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  19. * IN THE SOFTWARE.
  20. */
  21. #ifndef TOOLKIT_ERRNO_H_
  22. #define TOOLKIT_ERRNO_H_
  23. #include <errno.h>
  24. #if EDOM > 0
  25. # define TOOLKIT__ERR(x) (-(x))
  26. #else
  27. # define TOOLKIT__ERR(x) (x)
  28. #endif
  29. #define TOOLKIT__EOF (-4095)
  30. #define TOOLKIT__UNKNOWN (-4094)
  31. #define TOOLKIT__EAI_ADDRFAMILY (-3000)
  32. #define TOOLKIT__EAI_AGAIN (-3001)
  33. #define TOOLKIT__EAI_BADFLAGS (-3002)
  34. #define TOOLKIT__EAI_CANCELED (-3003)
  35. #define TOOLKIT__EAI_FAIL (-3004)
  36. #define TOOLKIT__EAI_FAMILY (-3005)
  37. #define TOOLKIT__EAI_MEMORY (-3006)
  38. #define TOOLKIT__EAI_NODATA (-3007)
  39. #define TOOLKIT__EAI_NONAME (-3008)
  40. #define TOOLKIT__EAI_OVERFLOW (-3009)
  41. #define TOOLKIT__EAI_SERVICE (-3010)
  42. #define TOOLKIT__EAI_SOCKTYPE (-3011)
  43. #define TOOLKIT__EAI_BADHINTS (-3013)
  44. #define TOOLKIT__EAI_PROTOCOL (-3014)
  45. /* Only map to the system errno on non-Windows platforms. It's apparently
  46. * a fairly common practice for Windows programmers to redefine errno codes.
  47. */
  48. #if defined(E2BIG) && !defined(_WIN32)
  49. # define TOOLKIT__E2BIG TOOLKIT__ERR(E2BIG)
  50. #else
  51. # define TOOLKIT__E2BIG (-4093)
  52. #endif
  53. #if defined(EACCES) && !defined(_WIN32)
  54. # define TOOLKIT__EACCES TOOLKIT__ERR(EACCES)
  55. #else
  56. # define TOOLKIT__EACCES (-4092)
  57. #endif
  58. #if defined(EADDRINUSE) && !defined(_WIN32)
  59. # define TOOLKIT__EADDRINUSE TOOLKIT__ERR(EADDRINUSE)
  60. #else
  61. # define TOOLKIT__EADDRINUSE (-4091)
  62. #endif
  63. #if defined(EADDRNOTAVAIL) && !defined(_WIN32)
  64. # define TOOLKIT__EADDRNOTAVAIL TOOLKIT__ERR(EADDRNOTAVAIL)
  65. #else
  66. # define TOOLKIT__EADDRNOTAVAIL (-4090)
  67. #endif
  68. #if defined(EAFNOSUPPORT) && !defined(_WIN32)
  69. # define TOOLKIT__EAFNOSUPPORT TOOLKIT__ERR(EAFNOSUPPORT)
  70. #else
  71. # define TOOLKIT__EAFNOSUPPORT (-4089)
  72. #endif
  73. #if defined(EAGAIN) && !defined(_WIN32)
  74. # define TOOLKIT__EAGAIN TOOLKIT__ERR(EAGAIN)
  75. #else
  76. # define TOOLKIT__EAGAIN (-4088)
  77. #endif
  78. #if defined(EALREADY) && !defined(_WIN32)
  79. # define TOOLKIT__EALREADY TOOLKIT__ERR(EALREADY)
  80. #else
  81. # define TOOLKIT__EALREADY (-4084)
  82. #endif
  83. #if defined(EBADF) && !defined(_WIN32)
  84. # define TOOLKIT__EBADF TOOLKIT__ERR(EBADF)
  85. #else
  86. # define TOOLKIT__EBADF (-4083)
  87. #endif
  88. #if defined(EBUSY) && !defined(_WIN32)
  89. # define TOOLKIT__EBUSY TOOLKIT__ERR(EBUSY)
  90. #else
  91. # define TOOLKIT__EBUSY (-4082)
  92. #endif
  93. #if defined(ECANCELED) && !defined(_WIN32)
  94. # define TOOLKIT__ECANCELED TOOLKIT__ERR(ECANCELED)
  95. #else
  96. # define TOOLKIT__ECANCELED (-4081)
  97. #endif
  98. #if defined(ECHARSET) && !defined(_WIN32)
  99. # define TOOLKIT__ECHARSET TOOLKIT__ERR(ECHARSET)
  100. #else
  101. # define TOOLKIT__ECHARSET (-4080)
  102. #endif
  103. #if defined(ECONNABORTED) && !defined(_WIN32)
  104. # define TOOLKIT__ECONNABORTED TOOLKIT__ERR(ECONNABORTED)
  105. #else
  106. # define TOOLKIT__ECONNABORTED (-4079)
  107. #endif
  108. #if defined(ECONNREFUSED) && !defined(_WIN32)
  109. # define TOOLKIT__ECONNREFUSED TOOLKIT__ERR(ECONNREFUSED)
  110. #else
  111. # define TOOLKIT__ECONNREFUSED (-4078)
  112. #endif
  113. #if defined(ECONNRESET) && !defined(_WIN32)
  114. # define TOOLKIT__ECONNRESET TOOLKIT__ERR(ECONNRESET)
  115. #else
  116. # define TOOLKIT__ECONNRESET (-4077)
  117. #endif
  118. #if defined(EDESTADDRREQ) && !defined(_WIN32)
  119. # define TOOLKIT__EDESTADDRREQ TOOLKIT__ERR(EDESTADDRREQ)
  120. #else
  121. # define TOOLKIT__EDESTADDRREQ (-4076)
  122. #endif
  123. #if defined(EEXIST) && !defined(_WIN32)
  124. # define TOOLKIT__EEXIST TOOLKIT__ERR(EEXIST)
  125. #else
  126. # define TOOLKIT__EEXIST (-4075)
  127. #endif
  128. #if defined(EFAULT) && !defined(_WIN32)
  129. # define TOOLKIT__EFAULT TOOLKIT__ERR(EFAULT)
  130. #else
  131. # define TOOLKIT__EFAULT (-4074)
  132. #endif
  133. #if defined(EHOSTUNREACH) && !defined(_WIN32)
  134. # define TOOLKIT__EHOSTUNREACH TOOLKIT__ERR(EHOSTUNREACH)
  135. #else
  136. # define TOOLKIT__EHOSTUNREACH (-4073)
  137. #endif
  138. #if defined(EINTR) && !defined(_WIN32)
  139. # define TOOLKIT__EINTR TOOLKIT__ERR(EINTR)
  140. #else
  141. # define TOOLKIT__EINTR (-4072)
  142. #endif
  143. #if defined(EINVAL) && !defined(_WIN32)
  144. # define TOOLKIT__EINVAL TOOLKIT__ERR(EINVAL)
  145. #else
  146. # define TOOLKIT__EINVAL (-4071)
  147. #endif
  148. #if defined(EIO) && !defined(_WIN32)
  149. # define TOOLKIT__EIO TOOLKIT__ERR(EIO)
  150. #else
  151. # define TOOLKIT__EIO (-4070)
  152. #endif
  153. #if defined(EISCONN) && !defined(_WIN32)
  154. # define TOOLKIT__EISCONN TOOLKIT__ERR(EISCONN)
  155. #else
  156. # define TOOLKIT__EISCONN (-4069)
  157. #endif
  158. #if defined(EISDIR) && !defined(_WIN32)
  159. # define TOOLKIT__EISDIR TOOLKIT__ERR(EISDIR)
  160. #else
  161. # define TOOLKIT__EISDIR (-4068)
  162. #endif
  163. #if defined(ELOOP) && !defined(_WIN32)
  164. # define TOOLKIT__ELOOP TOOLKIT__ERR(ELOOP)
  165. #else
  166. # define TOOLKIT__ELOOP (-4067)
  167. #endif
  168. #if defined(EMFILE) && !defined(_WIN32)
  169. # define TOOLKIT__EMFILE TOOLKIT__ERR(EMFILE)
  170. #else
  171. # define TOOLKIT__EMFILE (-4066)
  172. #endif
  173. #if defined(EMSGSIZE) && !defined(_WIN32)
  174. # define TOOLKIT__EMSGSIZE TOOLKIT__ERR(EMSGSIZE)
  175. #else
  176. # define TOOLKIT__EMSGSIZE (-4065)
  177. #endif
  178. #if defined(ENAMETOOLONG) && !defined(_WIN32)
  179. # define TOOLKIT__ENAMETOOLONG TOOLKIT__ERR(ENAMETOOLONG)
  180. #else
  181. # define TOOLKIT__ENAMETOOLONG (-4064)
  182. #endif
  183. #if defined(ENETDOWN) && !defined(_WIN32)
  184. # define TOOLKIT__ENETDOWN TOOLKIT__ERR(ENETDOWN)
  185. #else
  186. # define TOOLKIT__ENETDOWN (-4063)
  187. #endif
  188. #if defined(ENETUNREACH) && !defined(_WIN32)
  189. # define TOOLKIT__ENETUNREACH TOOLKIT__ERR(ENETUNREACH)
  190. #else
  191. # define TOOLKIT__ENETUNREACH (-4062)
  192. #endif
  193. #if defined(ENFILE) && !defined(_WIN32)
  194. # define TOOLKIT__ENFILE TOOLKIT__ERR(ENFILE)
  195. #else
  196. # define TOOLKIT__ENFILE (-4061)
  197. #endif
  198. #if defined(ENOBUFS) && !defined(_WIN32)
  199. # define TOOLKIT__ENOBUFS TOOLKIT__ERR(ENOBUFS)
  200. #else
  201. # define TOOLKIT__ENOBUFS (-4060)
  202. #endif
  203. #if defined(ENODEV) && !defined(_WIN32)
  204. # define TOOLKIT__ENODEV TOOLKIT__ERR(ENODEV)
  205. #else
  206. # define TOOLKIT__ENODEV (-4059)
  207. #endif
  208. #if defined(ENOENT) && !defined(_WIN32)
  209. # define TOOLKIT__ENOENT TOOLKIT__ERR(ENOENT)
  210. #else
  211. # define TOOLKIT__ENOENT (-4058)
  212. #endif
  213. #if defined(ENOMEM) && !defined(_WIN32)
  214. # define TOOLKIT__ENOMEM TOOLKIT__ERR(ENOMEM)
  215. #else
  216. # define TOOLKIT__ENOMEM (-4057)
  217. #endif
  218. #if defined(ENONET) && !defined(_WIN32)
  219. # define TOOLKIT__ENONET TOOLKIT__ERR(ENONET)
  220. #else
  221. # define TOOLKIT__ENONET (-4056)
  222. #endif
  223. #if defined(ENOSPC) && !defined(_WIN32)
  224. # define TOOLKIT__ENOSPC TOOLKIT__ERR(ENOSPC)
  225. #else
  226. # define TOOLKIT__ENOSPC (-4055)
  227. #endif
  228. #if defined(ENOSYS) && !defined(_WIN32)
  229. # define TOOLKIT__ENOSYS TOOLKIT__ERR(ENOSYS)
  230. #else
  231. # define TOOLKIT__ENOSYS (-4054)
  232. #endif
  233. #if defined(ENOTCONN) && !defined(_WIN32)
  234. # define TOOLKIT__ENOTCONN TOOLKIT__ERR(ENOTCONN)
  235. #else
  236. # define TOOLKIT__ENOTCONN (-4053)
  237. #endif
  238. #if defined(ENOTDIR) && !defined(_WIN32)
  239. # define TOOLKIT__ENOTDIR TOOLKIT__ERR(ENOTDIR)
  240. #else
  241. # define TOOLKIT__ENOTDIR (-4052)
  242. #endif
  243. #if defined(ENOTEMPTY) && !defined(_WIN32)
  244. # define TOOLKIT__ENOTEMPTY TOOLKIT__ERR(ENOTEMPTY)
  245. #else
  246. # define TOOLKIT__ENOTEMPTY (-4051)
  247. #endif
  248. #if defined(ENOTSOCK) && !defined(_WIN32)
  249. # define TOOLKIT__ENOTSOCK TOOLKIT__ERR(ENOTSOCK)
  250. #else
  251. # define TOOLKIT__ENOTSOCK (-4050)
  252. #endif
  253. #if defined(ENOTSUP) && !defined(_WIN32)
  254. # define TOOLKIT__ENOTSUP TOOLKIT__ERR(ENOTSUP)
  255. #else
  256. # define TOOLKIT__ENOTSUP (-4049)
  257. #endif
  258. #if defined(EPERM) && !defined(_WIN32)
  259. # define TOOLKIT__EPERM TOOLKIT__ERR(EPERM)
  260. #else
  261. # define TOOLKIT__EPERM (-4048)
  262. #endif
  263. #if defined(EPIPE) && !defined(_WIN32)
  264. # define TOOLKIT__EPIPE TOOLKIT__ERR(EPIPE)
  265. #else
  266. # define TOOLKIT__EPIPE (-4047)
  267. #endif
  268. #if defined(EPROTO) && !defined(_WIN32)
  269. # define TOOLKIT__EPROTO TOOLKIT__ERR(EPROTO)
  270. #else
  271. # define TOOLKIT__EPROTO TOOLKIT__ERR(4046)
  272. #endif
  273. #if defined(EPROTONOSUPPORT) && !defined(_WIN32)
  274. # define TOOLKIT__EPROTONOSUPPORT TOOLKIT__ERR(EPROTONOSUPPORT)
  275. #else
  276. # define TOOLKIT__EPROTONOSUPPORT (-4045)
  277. #endif
  278. #if defined(EPROTOTYPE) && !defined(_WIN32)
  279. # define TOOLKIT__EPROTOTYPE TOOLKIT__ERR(EPROTOTYPE)
  280. #else
  281. # define TOOLKIT__EPROTOTYPE (-4044)
  282. #endif
  283. #if defined(EROFS) && !defined(_WIN32)
  284. # define TOOLKIT__EROFS TOOLKIT__ERR(EROFS)
  285. #else
  286. # define TOOLKIT__EROFS (-4043)
  287. #endif
  288. #if defined(ESHUTDOWN) && !defined(_WIN32)
  289. # define TOOLKIT__ESHUTDOWN TOOLKIT__ERR(ESHUTDOWN)
  290. #else
  291. # define TOOLKIT__ESHUTDOWN (-4042)
  292. #endif
  293. #if defined(ESPIPE) && !defined(_WIN32)
  294. # define TOOLKIT__ESPIPE TOOLKIT__ERR(ESPIPE)
  295. #else
  296. # define TOOLKIT__ESPIPE (-4041)
  297. #endif
  298. #if defined(ESRCH) && !defined(_WIN32)
  299. # define TOOLKIT__ESRCH TOOLKIT__ERR(ESRCH)
  300. #else
  301. # define TOOLKIT__ESRCH (-4040)
  302. #endif
  303. #if defined(ETIMEDOUT) && !defined(_WIN32)
  304. # define TOOLKIT__ETIMEDOUT TOOLKIT__ERR(ETIMEDOUT)
  305. #else
  306. # define TOOLKIT__ETIMEDOUT (-4039)
  307. #endif
  308. #if defined(ETXTBSY) && !defined(_WIN32)
  309. # define TOOLKIT__ETXTBSY TOOLKIT__ERR(ETXTBSY)
  310. #else
  311. # define TOOLKIT__ETXTBSY (-4038)
  312. #endif
  313. #if defined(EXDEV) && !defined(_WIN32)
  314. # define TOOLKIT__EXDEV TOOLKIT__ERR(EXDEV)
  315. #else
  316. # define TOOLKIT__EXDEV (-4037)
  317. #endif
  318. #if defined(EFBIG) && !defined(_WIN32)
  319. # define TOOLKIT__EFBIG TOOLKIT__ERR(EFBIG)
  320. #else
  321. # define TOOLKIT__EFBIG (-4036)
  322. #endif
  323. #if defined(ENOPROTOOPT) && !defined(_WIN32)
  324. # define TOOLKIT__ENOPROTOOPT TOOLKIT__ERR(ENOPROTOOPT)
  325. #else
  326. # define TOOLKIT__ENOPROTOOPT (-4035)
  327. #endif
  328. #if defined(ERANGE) && !defined(_WIN32)
  329. # define TOOLKIT__ERANGE TOOLKIT__ERR(ERANGE)
  330. #else
  331. # define TOOLKIT__ERANGE (-4034)
  332. #endif
  333. #if defined(ENXIO) && !defined(_WIN32)
  334. # define TOOLKIT__ENXIO TOOLKIT__ERR(ENXIO)
  335. #else
  336. # define TOOLKIT__ENXIO (-4033)
  337. #endif
  338. #if defined(EMLINK) && !defined(_WIN32)
  339. # define TOOLKIT__EMLINK TOOLKIT__ERR(EMLINK)
  340. #else
  341. # define TOOLKIT__EMLINK (-4032)
  342. #endif
  343. /* EHOSTDOWN is not visible on BSD-like systems when _POSIX_C_SOURCE is
  344. * defined. Fortunately, its value is always 64 so it's possible albeit
  345. * icky to hard-code it.
  346. */
  347. #if defined(EHOSTDOWN) && !defined(_WIN32)
  348. # define TOOLKIT__EHOSTDOWN TOOLKIT__ERR(EHOSTDOWN)
  349. #elif defined(__APPLE__) || \
  350. defined(__DragonFly__) || \
  351. defined(__FreeBSD__) || \
  352. defined(__FreeBSD_kernel__) || \
  353. defined(__NetBSD__) || \
  354. defined(__OpenBSD__)
  355. # define TOOLKIT__EHOSTDOWN (-64)
  356. #else
  357. # define TOOLKIT__EHOSTDOWN (-4031)
  358. #endif
  359. #if defined(EREMOTEIO) && !defined(_WIN32)
  360. # define TOOLKIT__EREMOTEIO TOOLKIT__ERR(EREMOTEIO)
  361. #else
  362. # define TOOLKIT__EREMOTEIO (-4030)
  363. #endif
  364. #if defined(ENOTTY) && !defined(_WIN32)
  365. # define TOOLKIT__ENOTTY TOOLKIT__ERR(ENOTTY)
  366. #else
  367. # define TOOLKIT__ENOTTY (-4029)
  368. #endif
  369. #if defined(EFTYPE) && !defined(_WIN32)
  370. # define TOOLKIT__EFTYPE TOOLKIT__ERR(EFTYPE)
  371. #else
  372. # define TOOLKIT__EFTYPE (-4028)
  373. #endif
  374. #if defined(EILSEQ) && !defined(_WIN32)
  375. # define TOOLKIT__EILSEQ TOOLKIT__ERR(EILSEQ)
  376. #else
  377. # define TOOLKIT__EILSEQ (-4027)
  378. #endif
  379. #endif /* TOOLKIT_ERRNO_H_ */