Errno.swift 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573
  1. /*
  2. This source file is part of the Swift System open source project
  3. Copyright (c) 2020 - 2024 Apple Inc. and the Swift System project authors
  4. Licensed under Apache License v2.0 with Runtime Library Exception
  5. See https://swift.org/LICENSE.txt for license information
  6. */
  7. /// An error number used by system calls to communicate what kind of error
  8. /// occurred.
  9. @frozen
  10. @available(System 0.0.1, *)
  11. public struct Errno: RawRepresentable, Error, Hashable, Codable {
  12. /// The raw C error number.
  13. @_alwaysEmitIntoClient
  14. public let rawValue: CInt
  15. /// Creates a strongly typed error number from a raw C error number.
  16. @_alwaysEmitIntoClient
  17. public init(rawValue: CInt) { self.rawValue = rawValue }
  18. #if SYSTEM_PACKAGE_DARWIN
  19. /// Error. Not used.
  20. @_alwaysEmitIntoClient
  21. public static var notUsed: Errno { .init(rawValue: _ERRNO_NOT_USED) }
  22. @_alwaysEmitIntoClient
  23. @available(*, unavailable, renamed: "notUsed")
  24. public static var ERRNO_NOT_USED: Errno { notUsed }
  25. #endif
  26. /// Operation not permitted.
  27. ///
  28. /// An attempt was made to perform an operation
  29. /// limited to processes with appropriate privileges
  30. /// or to the owner of a file or other resources.
  31. ///
  32. /// The corresponding C error is `EPERM`.
  33. @_alwaysEmitIntoClient
  34. public static var notPermitted: Errno { .init(rawValue: _EPERM) }
  35. @_alwaysEmitIntoClient
  36. @available(*, unavailable, renamed: "notPermitted")
  37. public static var EPERM: Errno { notPermitted }
  38. /// No such file or directory.
  39. ///
  40. /// A component of a specified pathname didn't exist,
  41. /// or the pathname was an empty string.
  42. ///
  43. /// The corresponding C error is `ENOENT`.
  44. @_alwaysEmitIntoClient
  45. public static var noSuchFileOrDirectory: Errno { .init(rawValue: _ENOENT) }
  46. @_alwaysEmitIntoClient
  47. @available(*, unavailable, renamed: "noSuchFileOrDirectory")
  48. public static var ENOENT: Errno { noSuchFileOrDirectory }
  49. /// No such process.
  50. ///
  51. /// There isn't a process that corresponds to the specified process ID.
  52. ///
  53. /// The corresponding C error is `ESRCH`.
  54. @_alwaysEmitIntoClient
  55. public static var noSuchProcess: Errno { .init(rawValue: _ESRCH) }
  56. @_alwaysEmitIntoClient
  57. @available(*, unavailable, renamed: "noSuchProcess")
  58. public static var ESRCH: Errno { noSuchProcess }
  59. /// Interrupted function call.
  60. ///
  61. /// The process caught an asynchronous signal (such as `SIGINT` or `SIGQUIT`)
  62. /// during the execution of an interruptible function.
  63. /// If the signal handler performs a normal return,
  64. /// the caller of the interrupted function call receives this error.
  65. ///
  66. /// The corresponding C error is `EINTR`.
  67. @_alwaysEmitIntoClient
  68. public static var interrupted: Errno { .init(rawValue: _EINTR) }
  69. @_alwaysEmitIntoClient
  70. @available(*, unavailable, renamed: "interrupted")
  71. public static var EINTR: Errno { interrupted }
  72. /// Input/output error.
  73. ///
  74. /// Some physical input or output error occurred.
  75. /// This error isn't reported until
  76. /// you attempt a subsequent operation on the same file descriptor,
  77. /// and the error may be lost (overwritten) by subsequent errors.
  78. ///
  79. /// The corresponding C error is `EIO`.
  80. @_alwaysEmitIntoClient
  81. public static var ioError: Errno { .init(rawValue: _EIO) }
  82. @_alwaysEmitIntoClient
  83. @available(*, unavailable, renamed: "ioError")
  84. public static var EIO: Errno { ioError }
  85. /// No such device or address.
  86. ///
  87. /// Input or output on a special file referred to a device that didn't exist,
  88. /// or made a request beyond the limits of the device.
  89. /// This error may also occur when, for example,
  90. /// a tape drive isn't online or when there isn't a disk pack loaded on a drive.
  91. ///
  92. /// The corresponding C error is `ENXIO`.
  93. @_alwaysEmitIntoClient
  94. public static var noSuchAddressOrDevice: Errno { .init(rawValue: _ENXIO) }
  95. @_alwaysEmitIntoClient
  96. @available(*, unavailable, renamed: "noSuchAddressOrDevice")
  97. public static var ENXIO: Errno { noSuchAddressOrDevice }
  98. /// The argument list is too long.
  99. ///
  100. /// The number of bytes
  101. /// used for the argument and environment list of the new process
  102. /// exceeded the limit `NCARGS`, as defined in `<sys/param.h>`.
  103. ///
  104. /// The corresponding C error is `E2BIG`.
  105. @_alwaysEmitIntoClient
  106. public static var argListTooLong: Errno { .init(rawValue: _E2BIG) }
  107. @_alwaysEmitIntoClient
  108. @available(*, unavailable, renamed: "argListTooLong")
  109. public static var E2BIG: Errno { argListTooLong }
  110. /// Executable format error.
  111. ///
  112. /// A request was made to execute a file that,
  113. /// although it has the appropriate permissions,
  114. /// isn't in the format required for an executable file.
  115. ///
  116. /// The corresponding C error is `ENOEXEC`.
  117. @_alwaysEmitIntoClient
  118. public static var execFormatError: Errno { .init(rawValue: _ENOEXEC) }
  119. @_alwaysEmitIntoClient
  120. @available(*, unavailable, renamed: "execFormatError")
  121. public static var ENOEXEC: Errno { execFormatError }
  122. /// Bad file descriptor.
  123. ///
  124. /// A file descriptor argument was out of range,
  125. /// referred to no open file,
  126. /// or a read (write) request was made to a file
  127. /// that was only open for writing (reading).
  128. ///
  129. /// The corresponding C error is `EBADF`.
  130. @_alwaysEmitIntoClient
  131. public static var badFileDescriptor: Errno { .init(rawValue: _EBADF) }
  132. @_alwaysEmitIntoClient
  133. @available(*, unavailable, renamed: "badFileDescriptor")
  134. public static var EBADF: Errno { badFileDescriptor }
  135. /// No child processes.
  136. ///
  137. /// A `wait(2)` or `waitpid(2)` function was executed
  138. /// by a process that doesn't have any existing child processes
  139. /// or whose child processes are all already being waited for.
  140. ///
  141. /// The corresponding C error is `ECHILD`.
  142. @_alwaysEmitIntoClient
  143. public static var noChildProcess: Errno { .init(rawValue: _ECHILD) }
  144. @_alwaysEmitIntoClient
  145. @available(*, unavailable, renamed: "noChildProcess")
  146. public static var ECHILD: Errno { noChildProcess }
  147. /// Resource deadlock avoided.
  148. ///
  149. /// You attempted to lock a system resource
  150. /// that would have resulted in a deadlock.
  151. ///
  152. /// The corresponding C error is `EDEADLK`.
  153. @_alwaysEmitIntoClient
  154. public static var deadlock: Errno { .init(rawValue: _EDEADLK) }
  155. @_alwaysEmitIntoClient
  156. @available(*, unavailable, renamed: "deadlock")
  157. public static var EDEADLK: Errno { deadlock }
  158. /// Can't allocate memory.
  159. ///
  160. /// The new process image required more memory
  161. /// than was allowed by the hardware
  162. /// or by system-imposed memory management constraints.
  163. /// A lack of swap space is normally temporary;
  164. /// however, a lack of core is not.
  165. /// You can increase soft limits up to their corresponding hard limits.
  166. ///
  167. /// The corresponding C error is `ENOMEM`.
  168. @_alwaysEmitIntoClient
  169. public static var noMemory: Errno { .init(rawValue: _ENOMEM) }
  170. @_alwaysEmitIntoClient
  171. @available(*, unavailable, renamed: "noMemory")
  172. public static var ENOMEM: Errno { noMemory }
  173. /// Permission denied.
  174. ///
  175. /// You attempted to access a file
  176. /// in a way that's forbidden by the file's access permissions.
  177. ///
  178. /// The corresponding C error is `EACCES`.
  179. @_alwaysEmitIntoClient
  180. public static var permissionDenied: Errno { .init(rawValue: _EACCES) }
  181. @_alwaysEmitIntoClient
  182. @available(*, unavailable, renamed: "permissionDenied")
  183. public static var EACCES: Errno { permissionDenied }
  184. /// Bad address.
  185. ///
  186. /// An address passed as an argument to a system call was invalid.
  187. ///
  188. /// The corresponding C error is `EFAULT`.
  189. @_alwaysEmitIntoClient
  190. public static var badAddress: Errno { .init(rawValue: _EFAULT) }
  191. @_alwaysEmitIntoClient
  192. @available(*, unavailable, renamed: "badAddress")
  193. public static var EFAULT: Errno { badAddress }
  194. #if !os(Windows) && !os(WASI)
  195. /// Not a block device.
  196. ///
  197. /// You attempted a block device operation on a nonblock device or file.
  198. ///
  199. /// The corresponding C error is `ENOTBLK`.
  200. @_alwaysEmitIntoClient
  201. public static var notBlockDevice: Errno { .init(rawValue: _ENOTBLK) }
  202. @_alwaysEmitIntoClient
  203. @available(*, unavailable, renamed: "notBlockDevice")
  204. public static var ENOTBLK: Errno { notBlockDevice }
  205. #endif
  206. /// Resource busy.
  207. ///
  208. /// You attempted to use a system resource which was in use at the time,
  209. /// in a manner that would have conflicted with the request.
  210. ///
  211. /// The corresponding C error is `EBUSY`.
  212. @_alwaysEmitIntoClient
  213. public static var resourceBusy: Errno { .init(rawValue: _EBUSY) }
  214. @_alwaysEmitIntoClient
  215. @available(*, unavailable, renamed: "resourceBusy")
  216. public static var EBUSY: Errno { resourceBusy }
  217. /// File exists.
  218. ///
  219. /// An existing file was mentioned in an inappropriate context;
  220. /// for example, as the new link name in a link function.
  221. ///
  222. /// The corresponding C error is `EEXIST`.
  223. @_alwaysEmitIntoClient
  224. public static var fileExists: Errno { .init(rawValue: _EEXIST) }
  225. @_alwaysEmitIntoClient
  226. @available(*, unavailable, renamed: "fileExists")
  227. public static var EEXIST: Errno { fileExists }
  228. /// Improper link.
  229. ///
  230. /// You attempted to create a hard link to a file on another file system.
  231. ///
  232. /// The corresponding C error is `EXDEV`.
  233. @_alwaysEmitIntoClient
  234. public static var improperLink: Errno { .init(rawValue: _EXDEV) }
  235. @_alwaysEmitIntoClient
  236. @available(*, unavailable, renamed: "improperLink")
  237. public static var EXDEV: Errno { improperLink }
  238. /// Operation not supported by device.
  239. ///
  240. /// You attempted to apply an inappropriate function to a device;
  241. /// for example, trying to read a write-only device such as a printer.
  242. ///
  243. /// The corresponding C error is `ENODEV`.
  244. @_alwaysEmitIntoClient
  245. public static var operationNotSupportedByDevice: Errno { .init(rawValue: _ENODEV) }
  246. @_alwaysEmitIntoClient
  247. @available(*, unavailable, renamed: "operationNotSupportedByDevice")
  248. public static var ENODEV: Errno { operationNotSupportedByDevice }
  249. /// Not a directory.
  250. ///
  251. /// A component of the specified pathname exists,
  252. /// but it wasn't a directory,
  253. /// when a directory was expected.
  254. ///
  255. /// The corresponding C error is `ENOTDIR`.
  256. @_alwaysEmitIntoClient
  257. public static var notDirectory: Errno { .init(rawValue: _ENOTDIR) }
  258. @_alwaysEmitIntoClient
  259. @available(*, unavailable, renamed: "notDirectory")
  260. public static var ENOTDIR: Errno { notDirectory }
  261. /// Is a directory.
  262. ///
  263. /// You attempted to open a directory with write mode specified.
  264. /// Directories can be opened only in read mode.
  265. ///
  266. /// The corresponding C error is `EISDIR`.
  267. @_alwaysEmitIntoClient
  268. public static var isDirectory: Errno { .init(rawValue: _EISDIR) }
  269. @_alwaysEmitIntoClient
  270. @available(*, unavailable, renamed: "isDirectory")
  271. public static var EISDIR: Errno { isDirectory }
  272. /// Invalid argument.
  273. ///
  274. /// One or more of the specified arguments wasn't valid;
  275. /// for example, specifying an undefined signal to a signal or kill function.
  276. ///
  277. /// The corresponding C error is `EINVAL`.
  278. @_alwaysEmitIntoClient
  279. public static var invalidArgument: Errno { .init(rawValue: _EINVAL) }
  280. @_alwaysEmitIntoClient
  281. @available(*, unavailable, renamed: "invalidArgument")
  282. public static var EINVAL: Errno { invalidArgument }
  283. /// The system has too many open files.
  284. ///
  285. /// The maximum number of file descriptors
  286. /// allowable on the system has been reached;
  287. /// requests to open a file can't be satisfied
  288. /// until you close at least one file descriptor.
  289. ///
  290. /// The corresponding C error is `ENFILE`.
  291. @_alwaysEmitIntoClient
  292. public static var tooManyOpenFilesInSystem: Errno { .init(rawValue: _ENFILE) }
  293. @_alwaysEmitIntoClient
  294. @available(*, unavailable, renamed: "tooManyOpenFilesInSystem")
  295. public static var ENFILE: Errno { tooManyOpenFilesInSystem }
  296. /// This process has too many open files.
  297. ///
  298. /// To check the current limit,
  299. /// call the `getdtablesize` function.
  300. ///
  301. /// The corresponding C error is `EMFILE`.
  302. @_alwaysEmitIntoClient
  303. public static var tooManyOpenFiles: Errno { .init(rawValue: _EMFILE) }
  304. @_alwaysEmitIntoClient
  305. @available(*, unavailable, renamed: "tooManyOpenFiles")
  306. public static var EMFILE: Errno { tooManyOpenFiles }
  307. #if !os(Windows)
  308. /// Inappropriate control function.
  309. ///
  310. /// You attempted a control function
  311. /// that can't be performed on the specified file or device.
  312. /// For information about control functions, see `ioctl(2)`.
  313. ///
  314. /// The corresponding C error is `ENOTTY`.
  315. @_alwaysEmitIntoClient
  316. public static var inappropriateIOCTLForDevice: Errno { .init(rawValue: _ENOTTY) }
  317. @_alwaysEmitIntoClient
  318. @available(*, unavailable, renamed: "inappropriateIOCTLForDevice")
  319. public static var ENOTTY: Errno { inappropriateIOCTLForDevice }
  320. /// Text file busy.
  321. ///
  322. /// The new process was a pure procedure (shared text) file,
  323. /// which was already open for writing by another process,
  324. /// or while the pure procedure file was being executed,
  325. /// an open call requested write access.
  326. ///
  327. /// The corresponding C error is `ETXTBSY`.
  328. @_alwaysEmitIntoClient
  329. public static var textFileBusy: Errno { .init(rawValue: _ETXTBSY) }
  330. @_alwaysEmitIntoClient
  331. @available(*, unavailable, renamed: "textFileBusy")
  332. public static var ETXTBSY: Errno { textFileBusy }
  333. #endif
  334. /// The file is too large.
  335. ///
  336. /// The file exceeds the maximum size allowed by the file system.
  337. /// For example, the maximum size on UFS is about 2.1 gigabytes,
  338. /// and about 9,223 petabytes on HFS-Plus and Apple File System.
  339. ///
  340. /// The corresponding C error is `EFBIG`.
  341. @_alwaysEmitIntoClient
  342. public static var fileTooLarge: Errno { .init(rawValue: _EFBIG) }
  343. @_alwaysEmitIntoClient
  344. @available(*, unavailable, renamed: "fileTooLarge")
  345. public static var EFBIG: Errno { fileTooLarge }
  346. /// Device out of space.
  347. ///
  348. /// A write to an ordinary file,
  349. /// the creation of a directory or symbolic link,
  350. /// or the creation of a directory entry failed
  351. /// because there aren't any available disk blocks on the file system,
  352. /// or the allocation of an inode for a newly created file failed
  353. /// because there aren't any inodes available on the file system.
  354. ///
  355. /// The corresponding C error is `ENOSPC`.
  356. @_alwaysEmitIntoClient
  357. public static var noSpace: Errno { .init(rawValue: _ENOSPC) }
  358. @_alwaysEmitIntoClient
  359. @available(*, unavailable, renamed: "noSpace")
  360. public static var ENOSPC: Errno { noSpace }
  361. /// Illegal seek.
  362. ///
  363. /// An `lseek(2)` function was issued on a socket, pipe or FIFO.
  364. ///
  365. /// The corresponding C error is `ESPIPE`.
  366. @_alwaysEmitIntoClient
  367. public static var illegalSeek: Errno { .init(rawValue: _ESPIPE) }
  368. @_alwaysEmitIntoClient
  369. @available(*, unavailable, renamed: "illegalSeek")
  370. public static var ESPIPE: Errno { illegalSeek }
  371. /// Read-only file system.
  372. ///
  373. /// You attempted to modify a file or directory
  374. /// on a file system that was read-only at the time.
  375. ///
  376. /// The corresponding C error is `EROFS`.
  377. @_alwaysEmitIntoClient
  378. public static var readOnlyFileSystem: Errno { .init(rawValue: _EROFS) }
  379. @_alwaysEmitIntoClient
  380. @available(*, unavailable, renamed: "readOnlyFileSystem")
  381. public static var EROFS: Errno { readOnlyFileSystem }
  382. /// Too many links.
  383. ///
  384. /// The maximum number of hard links to a single file (32767)
  385. /// has been exceeded.
  386. ///
  387. /// The corresponding C error is `EMLINK`.
  388. @_alwaysEmitIntoClient
  389. public static var tooManyLinks: Errno { .init(rawValue: _EMLINK) }
  390. @_alwaysEmitIntoClient
  391. @available(*, unavailable, renamed: "tooManyLinks")
  392. public static var EMLINK: Errno { tooManyLinks }
  393. /// Broken pipe.
  394. ///
  395. /// You attempted to write to a pipe, socket, or FIFO
  396. /// that doesn't have a process reading its data.
  397. ///
  398. /// The corresponding C error is `EPIPE`.
  399. @_alwaysEmitIntoClient
  400. public static var brokenPipe: Errno { .init(rawValue: _EPIPE) }
  401. @_alwaysEmitIntoClient
  402. @available(*, unavailable, renamed: "brokenPipe")
  403. public static var EPIPE: Errno { brokenPipe }
  404. /// Numerical argument out of domain.
  405. ///
  406. /// A numerical input argument was outside the defined domain of the
  407. /// mathematical function.
  408. ///
  409. /// The corresponding C error is `EDOM`.
  410. @_alwaysEmitIntoClient
  411. public static var outOfDomain: Errno { .init(rawValue: _EDOM) }
  412. @_alwaysEmitIntoClient
  413. @available(*, unavailable, renamed: "outOfDomain")
  414. public static var EDOM: Errno { outOfDomain }
  415. /// Numerical result out of range.
  416. ///
  417. /// A numerical result of the function
  418. /// was too large to fit in the available space;
  419. /// for example, because it exceeded a floating point number's
  420. /// level of precision.
  421. ///
  422. /// The corresponding C error is `ERANGE`.
  423. @_alwaysEmitIntoClient
  424. public static var outOfRange: Errno { .init(rawValue: _ERANGE) }
  425. @_alwaysEmitIntoClient
  426. @available(*, unavailable, renamed: "outOfRange")
  427. public static var ERANGE: Errno { outOfRange }
  428. /// Resource temporarily unavailable.
  429. ///
  430. /// This is a temporary condition;
  431. /// later calls to the same routine may complete normally.
  432. /// Make the same function call again later.
  433. ///
  434. /// The corresponding C error is `EAGAIN`.
  435. @_alwaysEmitIntoClient
  436. public static var resourceTemporarilyUnavailable: Errno { .init(rawValue: _EAGAIN) }
  437. @_alwaysEmitIntoClient
  438. @available(*, unavailable, renamed: "resourceTemporarilyUnavailable")
  439. public static var EAGAIN: Errno { resourceTemporarilyUnavailable }
  440. /// Operation now in progress.
  441. ///
  442. /// You attempted an operation that takes a long time to complete,
  443. /// such as `connect(2)` or `connectx(2)`,
  444. /// on a nonblocking object.
  445. /// See also `fcntl(2)`.
  446. ///
  447. /// The corresponding C error is `EINPROGRESS`.
  448. @_alwaysEmitIntoClient
  449. public static var nowInProgress: Errno { .init(rawValue: _EINPROGRESS) }
  450. @_alwaysEmitIntoClient
  451. @available(*, unavailable, renamed: "nowInProgress")
  452. public static var EINPROGRESS: Errno { nowInProgress }
  453. /// Operation already in progress.
  454. ///
  455. /// You attempted an operation on a nonblocking object
  456. /// that already had an operation in progress.
  457. ///
  458. /// The corresponding C error is `EALREADY`.
  459. @_alwaysEmitIntoClient
  460. public static var alreadyInProcess: Errno { .init(rawValue: _EALREADY) }
  461. @_alwaysEmitIntoClient
  462. @available(*, unavailable, renamed: "alreadyInProcess")
  463. public static var EALREADY: Errno { alreadyInProcess }
  464. /// A socket operation was performed on something that isn't a socket.
  465. ///
  466. /// The corresponding C error is `ENOTSOCK`.
  467. @_alwaysEmitIntoClient
  468. public static var notSocket: Errno { .init(rawValue: _ENOTSOCK) }
  469. @_alwaysEmitIntoClient
  470. @available(*, unavailable, renamed: "notSocket")
  471. public static var ENOTSOCK: Errno { notSocket }
  472. /// Destination address required.
  473. ///
  474. /// A required address was omitted from a socket operation.
  475. ///
  476. /// The corresponding C error is `EDESTADDRREQ`.
  477. @_alwaysEmitIntoClient
  478. public static var addressRequired: Errno { .init(rawValue: _EDESTADDRREQ) }
  479. @_alwaysEmitIntoClient
  480. @available(*, unavailable, renamed: "addressRequired")
  481. public static var EDESTADDRREQ: Errno { addressRequired }
  482. /// Message too long.
  483. ///
  484. /// A message sent on a socket was larger than
  485. /// the internal message buffer or some other network limit.
  486. ///
  487. /// The corresponding C error is `EMSGSIZE`.
  488. @_alwaysEmitIntoClient
  489. public static var messageTooLong: Errno { .init(rawValue: _EMSGSIZE) }
  490. @_alwaysEmitIntoClient
  491. @available(*, unavailable, renamed: "messageTooLong")
  492. public static var EMSGSIZE: Errno { messageTooLong }
  493. /// Protocol wrong for socket type.
  494. ///
  495. /// A protocol was specified that doesn't support
  496. /// the semantics of the socket type requested.
  497. /// For example,
  498. /// you can't use the ARPA Internet UDP protocol with type `SOCK_STREAM`.
  499. ///
  500. /// The corresponding C error is `EPROTOTYPE`.
  501. @_alwaysEmitIntoClient
  502. public static var protocolWrongTypeForSocket: Errno { .init(rawValue: _EPROTOTYPE) }
  503. @_alwaysEmitIntoClient
  504. @available(*, unavailable, renamed: "protocolWrongTypeForSocket")
  505. public static var EPROTOTYPE: Errno { protocolWrongTypeForSocket }
  506. /// Protocol not available.
  507. ///
  508. /// A bad option or level was specified
  509. /// in a `getsockopt(2)` or `setsockopt(2)` call.
  510. ///
  511. /// The corresponding C error is `ENOPROTOOPT`.
  512. @_alwaysEmitIntoClient
  513. public static var protocolNotAvailable: Errno { .init(rawValue: _ENOPROTOOPT) }
  514. @_alwaysEmitIntoClient
  515. @available(*, unavailable, renamed: "protocolNotAvailable")
  516. public static var ENOPROTOOPT: Errno { protocolNotAvailable }
  517. /// Protocol not supported.
  518. ///
  519. /// The protocol hasn't been configured into the system,
  520. /// or no implementation for it exists.
  521. ///
  522. /// The corresponding C error is `EPROTONOSUPPORT`.
  523. @_alwaysEmitIntoClient
  524. public static var protocolNotSupported: Errno { .init(rawValue: _EPROTONOSUPPORT) }
  525. @_alwaysEmitIntoClient
  526. @available(*, unavailable, renamed: "protocolNotSupported")
  527. public static var EPROTONOSUPPORT: Errno { protocolNotSupported }
  528. #if !os(WASI)
  529. /// Socket type not supported.
  530. ///
  531. /// Support for the socket type hasn't been configured into the system
  532. /// or no implementation for it exists.
  533. ///
  534. /// The corresponding C error is `ESOCKTNOSUPPORT`.
  535. @_alwaysEmitIntoClient
  536. public static var socketTypeNotSupported: Errno { .init(rawValue: _ESOCKTNOSUPPORT) }
  537. @_alwaysEmitIntoClient
  538. @available(*, unavailable, renamed: "socketTypeNotSupported")
  539. public static var ESOCKTNOSUPPORT: Errno { socketTypeNotSupported }
  540. #endif
  541. /// Not supported.
  542. ///
  543. /// The attempted operation isn't supported
  544. /// for the type of object referenced.
  545. ///
  546. /// The corresponding C error is `ENOTSUP`.
  547. @_alwaysEmitIntoClient
  548. public static var notSupported: Errno { .init(rawValue: _ENOTSUP) }
  549. @_alwaysEmitIntoClient
  550. @available(*, unavailable, renamed: "notSupported")
  551. public static var ENOTSUP: Errno { notSupported }
  552. #if !os(WASI)
  553. /// Protocol family not supported.
  554. ///
  555. /// The protocol family hasn't been configured into the system
  556. /// or no implementation for it exists.
  557. ///
  558. /// The corresponding C error is `EPFNOSUPPORT`.
  559. @_alwaysEmitIntoClient
  560. public static var protocolFamilyNotSupported: Errno { .init(rawValue: _EPFNOSUPPORT) }
  561. @_alwaysEmitIntoClient
  562. @available(*, unavailable, renamed: "protocolFamilyNotSupported")
  563. public static var EPFNOSUPPORT: Errno { protocolFamilyNotSupported }
  564. #endif
  565. /// The address family isn't supported by the protocol family.
  566. ///
  567. /// An address incompatible with the requested protocol was used.
  568. /// For example, you shouldn't necessarily expect
  569. /// to be able to use name server addresses with ARPA Internet protocols.
  570. ///
  571. /// The corresponding C error is `EAFNOSUPPORT`.
  572. @_alwaysEmitIntoClient
  573. public static var addressFamilyNotSupported: Errno { .init(rawValue: _EAFNOSUPPORT) }
  574. @_alwaysEmitIntoClient
  575. @available(*, unavailable, renamed: "addressFamilyNotSupported")
  576. public static var EAFNOSUPPORT: Errno { addressFamilyNotSupported }
  577. /// Address already in use.
  578. ///
  579. /// Only one use of each address is normally permitted.
  580. ///
  581. /// The corresponding C error is `EADDRINUSE`.
  582. @_alwaysEmitIntoClient
  583. public static var addressInUse: Errno { .init(rawValue: _EADDRINUSE) }
  584. @_alwaysEmitIntoClient
  585. @available(*, unavailable, renamed: "addressInUse")
  586. public static var EADDRINUSE: Errno { addressInUse }
  587. /// Can't assign the requested address.
  588. ///
  589. /// This error normally results from
  590. /// an attempt to create a socket with an address that isn't on this machine.
  591. ///
  592. /// The corresponding C error is `EADDRNOTAVAIL`.
  593. @_alwaysEmitIntoClient
  594. public static var addressNotAvailable: Errno { .init(rawValue: _EADDRNOTAVAIL) }
  595. @_alwaysEmitIntoClient
  596. @available(*, unavailable, renamed: "addressNotAvailable")
  597. public static var EADDRNOTAVAIL: Errno { addressNotAvailable }
  598. /// Network is down.
  599. ///
  600. /// A socket operation encountered a dead network.
  601. ///
  602. /// The corresponding C error is `ENETDOWN`.
  603. @_alwaysEmitIntoClient
  604. public static var networkDown: Errno { .init(rawValue: _ENETDOWN) }
  605. @_alwaysEmitIntoClient
  606. @available(*, unavailable, renamed: "networkDown")
  607. public static var ENETDOWN: Errno { networkDown }
  608. /// Network is unreachable.
  609. ///
  610. /// A socket operation was attempted to an unreachable network.
  611. ///
  612. /// The corresponding C error is `ENETUNREACH`.
  613. @_alwaysEmitIntoClient
  614. public static var networkUnreachable: Errno { .init(rawValue: _ENETUNREACH) }
  615. @_alwaysEmitIntoClient
  616. @available(*, unavailable, renamed: "networkUnreachable")
  617. public static var ENETUNREACH: Errno { networkUnreachable }
  618. /// Network dropped connection on reset.
  619. ///
  620. /// The host you were connected to crashed and restarted.
  621. ///
  622. /// The corresponding C error is `ENETRESET`.
  623. @_alwaysEmitIntoClient
  624. public static var networkReset: Errno { .init(rawValue: _ENETRESET) }
  625. @_alwaysEmitIntoClient
  626. @available(*, unavailable, renamed: "networkReset")
  627. public static var ENETRESET: Errno { networkReset }
  628. /// Software caused a connection abort.
  629. ///
  630. /// A connection abort was caused internal to your host machine.
  631. ///
  632. /// The corresponding C error is `ECONNABORTED`.
  633. @_alwaysEmitIntoClient
  634. public static var connectionAbort: Errno { .init(rawValue: _ECONNABORTED) }
  635. @_alwaysEmitIntoClient
  636. @available(*, unavailable, renamed: "connectionAbort")
  637. public static var ECONNABORTED: Errno { connectionAbort }
  638. /// Connection reset by peer.
  639. ///
  640. /// A connection was forcibly closed by a peer.
  641. /// This normally results from a loss of the connection
  642. /// on the remote socket due to a timeout or a reboot.
  643. ///
  644. /// The corresponding C error is `ECONNRESET`.
  645. @_alwaysEmitIntoClient
  646. public static var connectionReset: Errno { .init(rawValue: _ECONNRESET) }
  647. @_alwaysEmitIntoClient
  648. @available(*, unavailable, renamed: "connectionReset")
  649. public static var ECONNRESET: Errno { connectionReset }
  650. /// No buffer space available.
  651. ///
  652. /// An operation on a socket or pipe wasn't performed
  653. /// because the system lacked sufficient buffer space
  654. /// or because a queue was full.
  655. ///
  656. /// The corresponding C error is `ENOBUFS`.
  657. @_alwaysEmitIntoClient
  658. public static var noBufferSpace: Errno { .init(rawValue: _ENOBUFS) }
  659. @_alwaysEmitIntoClient
  660. @available(*, unavailable, renamed: "noBufferSpace")
  661. public static var ENOBUFS: Errno { noBufferSpace }
  662. /// Socket is already connected.
  663. ///
  664. /// A `connect(2)` or `connectx(2)` request was made
  665. /// on an already connected socket,
  666. /// or a `sendto(2)` or `sendmsg(2)` request was made
  667. /// on a connected socket specified a destination when already connected.
  668. ///
  669. /// The corresponding C error is `EISCONN`.
  670. @_alwaysEmitIntoClient
  671. public static var socketIsConnected: Errno { .init(rawValue: _EISCONN) }
  672. @_alwaysEmitIntoClient
  673. @available(*, unavailable, renamed: "socketIsConnected")
  674. public static var EISCONN: Errno { socketIsConnected }
  675. /// Socket is not connected.
  676. ///
  677. /// A request to send or receive data wasn't permitted
  678. /// because the socket wasn't connected and,
  679. /// when sending on a datagram socket,
  680. /// no address was supplied.
  681. ///
  682. /// The corresponding C error is `ENOTCONN`.
  683. @_alwaysEmitIntoClient
  684. public static var socketNotConnected: Errno { .init(rawValue: _ENOTCONN) }
  685. @_alwaysEmitIntoClient
  686. @available(*, unavailable, renamed: "socketNotConnected")
  687. public static var ENOTCONN: Errno { socketNotConnected }
  688. #if !os(WASI)
  689. /// Can't send after socket shutdown.
  690. ///
  691. /// A request to send data wasn't permitted
  692. /// because the socket had already been shut down
  693. /// with a previous `shutdown(2)` call.
  694. ///
  695. /// The corresponding C error is `ESHUTDOWN`.
  696. @_alwaysEmitIntoClient
  697. public static var socketShutdown: Errno { .init(rawValue: _ESHUTDOWN) }
  698. @_alwaysEmitIntoClient
  699. @available(*, unavailable, renamed: "socketShutdown")
  700. public static var ESHUTDOWN: Errno { socketShutdown }
  701. #endif
  702. /// Operation timed out.
  703. ///
  704. /// A `connect(2)`, `connectx(2)` or `send(2)` request failed
  705. /// because the connected party didn't properly respond
  706. /// within the required period of time.
  707. /// The timeout period is dependent on the communication protocol.
  708. ///
  709. /// The corresponding C error is `ETIMEDOUT`.
  710. @_alwaysEmitIntoClient
  711. public static var timedOut: Errno { .init(rawValue: _ETIMEDOUT) }
  712. @_alwaysEmitIntoClient
  713. @available(*, unavailable, renamed: "timedOut")
  714. public static var ETIMEDOUT: Errno { timedOut }
  715. /// Connection refused.
  716. ///
  717. /// No connection could be made
  718. /// because the target machine actively refused it.
  719. /// This usually results from trying to connect to a service
  720. /// that's inactive on the foreign host.
  721. ///
  722. /// The corresponding C error is `ECONNREFUSED`.
  723. @_alwaysEmitIntoClient
  724. public static var connectionRefused: Errno { .init(rawValue: _ECONNREFUSED) }
  725. @_alwaysEmitIntoClient
  726. @available(*, unavailable, renamed: "connectionRefused")
  727. public static var ECONNREFUSED: Errno { connectionRefused }
  728. /// Too many levels of symbolic links.
  729. ///
  730. /// A pathname lookup involved more than eight symbolic links.
  731. ///
  732. /// The corresponding C error is `ELOOP`.
  733. @_alwaysEmitIntoClient
  734. public static var tooManySymbolicLinkLevels: Errno { .init(rawValue: _ELOOP) }
  735. @_alwaysEmitIntoClient
  736. @available(*, unavailable, renamed: "tooManySymbolicLinkLevels")
  737. public static var ELOOP: Errno { tooManySymbolicLinkLevels }
  738. /// The file name is too long.
  739. ///
  740. /// A component of a pathname exceeded 255 (`MAXNAMELEN`) characters,
  741. /// or an entire pathname exceeded 1023 (`MAXPATHLEN-1`) characters.
  742. ///
  743. /// The corresponding C error is `ENAMETOOLONG`.
  744. @_alwaysEmitIntoClient
  745. public static var fileNameTooLong: Errno { .init(rawValue: _ENAMETOOLONG) }
  746. @_alwaysEmitIntoClient
  747. @available(*, unavailable, renamed: "fileNameTooLong")
  748. public static var ENAMETOOLONG: Errno { fileNameTooLong }
  749. #if !os(WASI)
  750. /// The host is down.
  751. ///
  752. /// A socket operation failed because the destination host was down.
  753. ///
  754. /// The corresponding C error is `EHOSTDOWN`.
  755. @_alwaysEmitIntoClient
  756. public static var hostIsDown: Errno { .init(rawValue: _EHOSTDOWN) }
  757. @_alwaysEmitIntoClient
  758. @available(*, unavailable, renamed: "hostIsDown")
  759. public static var EHOSTDOWN: Errno { hostIsDown }
  760. #endif
  761. /// No route to host.
  762. ///
  763. /// A socket operation failed because the destination host was unreachable.
  764. ///
  765. /// The corresponding C error is `EHOSTUNREACH`.
  766. @_alwaysEmitIntoClient
  767. public static var noRouteToHost: Errno { .init(rawValue: _EHOSTUNREACH) }
  768. @_alwaysEmitIntoClient
  769. @available(*, unavailable, renamed: "noRouteToHost")
  770. public static var EHOSTUNREACH: Errno { noRouteToHost }
  771. /// Directory not empty.
  772. ///
  773. /// A directory with entries other than `.` and `..`
  774. /// was supplied to a `remove(2)` directory or `rename(2)` call.
  775. ///
  776. /// The corresponding C error is `ENOTEMPTY`.
  777. @_alwaysEmitIntoClient
  778. public static var directoryNotEmpty: Errno { .init(rawValue: _ENOTEMPTY) }
  779. @_alwaysEmitIntoClient
  780. @available(*, unavailable, renamed: "directoryNotEmpty")
  781. public static var ENOTEMPTY: Errno { directoryNotEmpty }
  782. #if SYSTEM_PACKAGE_DARWIN
  783. /// Too many processes.
  784. ///
  785. /// The corresponding C error is `EPROCLIM`.
  786. @_alwaysEmitIntoClient
  787. public static var tooManyProcesses: Errno { .init(rawValue: _EPROCLIM) }
  788. @_alwaysEmitIntoClient
  789. @available(*, unavailable, renamed: "tooManyProcesses")
  790. public static var EPROCLIM: Errno { tooManyProcesses }
  791. #endif
  792. #if !os(WASI)
  793. /// Too many users.
  794. ///
  795. /// The quota system ran out of table entries.
  796. ///
  797. /// The corresponding C error is `EUSERS`.
  798. @_alwaysEmitIntoClient
  799. public static var tooManyUsers: Errno { .init(rawValue: _EUSERS) }
  800. @_alwaysEmitIntoClient
  801. @available(*, unavailable, renamed: "tooManyUsers")
  802. public static var EUSERS: Errno { tooManyUsers }
  803. #endif
  804. /// Disk quota exceeded.
  805. ///
  806. /// A write to an ordinary file,
  807. /// the creation of a directory or symbolic link,
  808. /// or the creation of a directory entry failed
  809. /// because the user's quota of disk blocks was exhausted,
  810. /// or the allocation of an inode for a newly created file failed
  811. /// because the user's quota of inodes was exhausted.
  812. ///
  813. /// The corresponding C error is `EDQUOT`.
  814. @_alwaysEmitIntoClient
  815. public static var diskQuotaExceeded: Errno { .init(rawValue: _EDQUOT) }
  816. @_alwaysEmitIntoClient
  817. @available(*, unavailable, renamed: "diskQuotaExceeded")
  818. public static var EDQUOT: Errno { diskQuotaExceeded }
  819. /// Stale NFS file handle.
  820. ///
  821. /// You attempted access an open file on an NFS file system,
  822. /// which is now unavailable as referenced by the given file descriptor.
  823. /// This may indicate that the file was deleted on the NFS server
  824. /// or that some other catastrophic event occurred.
  825. ///
  826. /// The corresponding C error is `ESTALE`.
  827. @_alwaysEmitIntoClient
  828. public static var staleNFSFileHandle: Errno { .init(rawValue: _ESTALE) }
  829. @_alwaysEmitIntoClient
  830. @available(*, unavailable, renamed: "staleNFSFileHandle")
  831. public static var ESTALE: Errno { staleNFSFileHandle }
  832. // TODO: Add Linux's RPC equivalents
  833. #if SYSTEM_PACKAGE_DARWIN
  834. /// The structure of the remote procedure call (RPC) is bad.
  835. ///
  836. /// Exchange of RPC information was unsuccessful.
  837. ///
  838. /// The corresponding C error is `EBADRPC`.
  839. @_alwaysEmitIntoClient
  840. public static var rpcUnsuccessful: Errno { .init(rawValue: _EBADRPC) }
  841. @_alwaysEmitIntoClient
  842. @available(*, unavailable, renamed: "rpcUnsuccessful")
  843. public static var EBADRPC: Errno { rpcUnsuccessful }
  844. /// The version of the remote procedure call (RPC) is incorrect.
  845. ///
  846. /// The version of RPC on the remote peer
  847. /// isn't compatible with the local version.
  848. ///
  849. /// The corresponding C error is `ERPCMISMATCH`.
  850. @_alwaysEmitIntoClient
  851. public static var rpcVersionMismatch: Errno { .init(rawValue: _ERPCMISMATCH) }
  852. @_alwaysEmitIntoClient
  853. @available(*, unavailable, renamed: "rpcVersionMismatch")
  854. public static var ERPCMISMATCH: Errno { rpcVersionMismatch }
  855. /// The remote procedure call (RPC) program isn't available.
  856. ///
  857. /// The requested program isn't registered on the remote host.
  858. ///
  859. /// The corresponding C error is `EPROGUNAVAIL`.
  860. @_alwaysEmitIntoClient
  861. public static var rpcProgramUnavailable: Errno { .init(rawValue: _EPROGUNAVAIL) }
  862. @_alwaysEmitIntoClient
  863. @available(*, unavailable, renamed: "rpcProgramUnavailable")
  864. public static var EPROGUNAVAIL: Errno { rpcProgramUnavailable }
  865. /// The version of the remote procedure call (RPC) program is incorrect.
  866. ///
  867. /// The requested version of the program
  868. /// isn't available on the remote host.
  869. ///
  870. /// The corresponding C error is `EPROGMISMATCH`.
  871. @_alwaysEmitIntoClient
  872. public static var rpcProgramVersionMismatch: Errno { .init(rawValue: _EPROGMISMATCH) }
  873. @_alwaysEmitIntoClient
  874. @available(*, unavailable, renamed: "rpcProgramVersionMismatch")
  875. public static var EPROGMISMATCH: Errno { rpcProgramVersionMismatch }
  876. /// Bad procedure for program.
  877. ///
  878. /// A remote procedure call was attempted for a procedure
  879. /// that doesn't exist in the remote program.
  880. ///
  881. /// The corresponding C error is `EPROCUNAVAIL`.
  882. @_alwaysEmitIntoClient
  883. public static var rpcProcedureUnavailable: Errno { .init(rawValue: _EPROCUNAVAIL) }
  884. @_alwaysEmitIntoClient
  885. @available(*, unavailable, renamed: "rpcProcedureUnavailable")
  886. public static var EPROCUNAVAIL: Errno { rpcProcedureUnavailable }
  887. #endif
  888. /// No locks available.
  889. ///
  890. /// You have reached the system-imposed limit
  891. /// on the number of simultaneous files.
  892. ///
  893. /// The corresponding C error is `ENOLCK`.
  894. @_alwaysEmitIntoClient
  895. public static var noLocks: Errno { .init(rawValue: _ENOLCK) }
  896. @_alwaysEmitIntoClient
  897. @available(*, unavailable, renamed: "noLocks")
  898. public static var ENOLCK: Errno { noLocks }
  899. /// Function not implemented.
  900. ///
  901. /// You attempted a system call that isn't available on this system.
  902. ///
  903. /// The corresponding C error is `ENOSYS`.
  904. @_alwaysEmitIntoClient
  905. public static var noFunction: Errno { .init(rawValue: _ENOSYS) }
  906. @_alwaysEmitIntoClient
  907. @available(*, unavailable, renamed: "noFunction")
  908. public static var ENOSYS: Errno { noFunction }
  909. // BSD
  910. #if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
  911. /// Inappropriate file type or format.
  912. ///
  913. /// The file was the wrong type for the operation,
  914. /// or a data file had the wrong format.
  915. ///
  916. /// The corresponding C error is `EFTYPE`.
  917. @_alwaysEmitIntoClient
  918. public static var badFileTypeOrFormat: Errno { .init(rawValue: _EFTYPE) }
  919. @_alwaysEmitIntoClient
  920. @available(*, unavailable, renamed: "badFileTypeOrFormat")
  921. public static var EFTYPE: Errno { badFileTypeOrFormat }
  922. #endif
  923. #if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
  924. /// Authentication error.
  925. ///
  926. /// The authentication ticket used to mount an NFS file system was invalid.
  927. ///
  928. /// The corresponding C error is `EAUTH`.
  929. @_alwaysEmitIntoClient
  930. public static var authenticationError: Errno { .init(rawValue: _EAUTH) }
  931. @_alwaysEmitIntoClient
  932. @available(*, unavailable, renamed: "authenticationError")
  933. public static var EAUTH: Errno { authenticationError }
  934. /// Need authenticator.
  935. ///
  936. /// Before mounting the given NFS file system,
  937. /// you must obtain an authentication ticket.
  938. ///
  939. /// The corresponding C error is `ENEEDAUTH`.
  940. @_alwaysEmitIntoClient
  941. public static var needAuthenticator: Errno { .init(rawValue: _ENEEDAUTH) }
  942. @_alwaysEmitIntoClient
  943. @available(*, unavailable, renamed: "needAuthenticator")
  944. public static var ENEEDAUTH: Errno { needAuthenticator }
  945. #endif
  946. #if SYSTEM_PACKAGE_DARWIN
  947. /// Device power is off.
  948. ///
  949. /// The corresponding C error is `EPWROFF`.
  950. @_alwaysEmitIntoClient
  951. public static var devicePowerIsOff: Errno { .init(rawValue: _EPWROFF) }
  952. @_alwaysEmitIntoClient
  953. @available(*, unavailable, renamed: "devicePowerIsOff")
  954. public static var EPWROFF: Errno { devicePowerIsOff }
  955. /// Device error.
  956. ///
  957. /// A device error has occurred;
  958. /// for example, a printer running out of paper.
  959. ///
  960. /// The corresponding C error is `EDEVERR`.
  961. @_alwaysEmitIntoClient
  962. public static var deviceError: Errno { .init(rawValue: _EDEVERR) }
  963. @_alwaysEmitIntoClient
  964. @available(*, unavailable, renamed: "deviceError")
  965. public static var EDEVERR: Errno { deviceError }
  966. #endif
  967. #if !os(Windows)
  968. /// Value too large to be stored in data type.
  969. ///
  970. /// A numerical result of the function
  971. /// is too large to be stored in the space that the caller provided.
  972. ///
  973. /// The corresponding C error is `EOVERFLOW`.
  974. @_alwaysEmitIntoClient
  975. public static var overflow: Errno { .init(rawValue: _EOVERFLOW) }
  976. @_alwaysEmitIntoClient
  977. @available(*, unavailable, renamed: "overflow")
  978. public static var EOVERFLOW: Errno { overflow }
  979. #endif
  980. #if SYSTEM_PACKAGE_DARWIN
  981. /// Bad executable or shared library.
  982. ///
  983. /// The executable or shared library being referenced was malformed.
  984. ///
  985. /// The corresponding C error is `EBADEXEC`.
  986. @_alwaysEmitIntoClient
  987. public static var badExecutable: Errno { .init(rawValue: _EBADEXEC) }
  988. @_alwaysEmitIntoClient
  989. @available(*, unavailable, renamed: "badExecutable")
  990. public static var EBADEXEC: Errno { badExecutable }
  991. /// Bad CPU type in executable.
  992. ///
  993. /// The specified executable doesn't support the current CPU.
  994. ///
  995. /// The corresponding C error is `EBADARCH`.
  996. @_alwaysEmitIntoClient
  997. public static var badCPUType: Errno { .init(rawValue: _EBADARCH) }
  998. @_alwaysEmitIntoClient
  999. @available(*, unavailable, renamed: "badCPUType")
  1000. public static var EBADARCH: Errno { badCPUType }
  1001. /// Shared library version mismatch.
  1002. ///
  1003. /// The version of the shared library on the system
  1004. /// doesn't match the expected version.
  1005. ///
  1006. /// The corresponding C error is `ESHLIBVERS`.
  1007. @_alwaysEmitIntoClient
  1008. public static var sharedLibraryVersionMismatch: Errno { .init(rawValue: _ESHLIBVERS) }
  1009. @_alwaysEmitIntoClient
  1010. @available(*, unavailable, renamed: "sharedLibraryVersionMismatch")
  1011. public static var ESHLIBVERS: Errno { sharedLibraryVersionMismatch }
  1012. /// Malformed Mach-O file.
  1013. ///
  1014. /// The Mach object file is malformed.
  1015. ///
  1016. /// The corresponding C error is `EBADMACHO`.
  1017. @_alwaysEmitIntoClient
  1018. public static var malformedMachO: Errno { .init(rawValue: _EBADMACHO) }
  1019. @_alwaysEmitIntoClient
  1020. @available(*, unavailable, renamed: "malformedMachO")
  1021. public static var EBADMACHO: Errno { malformedMachO }
  1022. #endif
  1023. /// Operation canceled.
  1024. ///
  1025. /// The scheduled operation was canceled.
  1026. ///
  1027. /// The corresponding C error is `ECANCELED`.
  1028. @_alwaysEmitIntoClient
  1029. public static var canceled: Errno { .init(rawValue: _ECANCELED) }
  1030. @_alwaysEmitIntoClient
  1031. @available(*, unavailable, renamed: "canceled")
  1032. public static var ECANCELED: Errno { canceled }
  1033. #if !os(Windows)
  1034. /// Identifier removed.
  1035. ///
  1036. /// An IPC identifier was removed while the current process was waiting on it.
  1037. ///
  1038. /// The corresponding C error is `EIDRM`.
  1039. @_alwaysEmitIntoClient
  1040. public static var identifierRemoved: Errno { .init(rawValue: _EIDRM) }
  1041. @_alwaysEmitIntoClient
  1042. @available(*, unavailable, renamed: "identifierRemoved")
  1043. public static var EIDRM: Errno { identifierRemoved }
  1044. /// No message of desired type.
  1045. ///
  1046. /// An IPC message queue doesn't contain a message of the desired type,
  1047. /// or a message catalog doesn't contain the requested message.
  1048. ///
  1049. /// The corresponding C error is `ENOMSG`.
  1050. @_alwaysEmitIntoClient
  1051. public static var noMessage: Errno { .init(rawValue: _ENOMSG) }
  1052. @_alwaysEmitIntoClient
  1053. @available(*, unavailable, renamed: "noMessage")
  1054. public static var ENOMSG: Errno { noMessage }
  1055. #endif
  1056. /// Illegal byte sequence.
  1057. ///
  1058. /// While decoding a multibyte character,
  1059. /// the function encountered an invalid or incomplete sequence of bytes,
  1060. /// or the given wide character is invalid.
  1061. ///
  1062. /// The corresponding C error is `EILSEQ`.
  1063. @_alwaysEmitIntoClient
  1064. public static var illegalByteSequence: Errno { .init(rawValue: _EILSEQ) }
  1065. @_alwaysEmitIntoClient
  1066. @available(*, unavailable, renamed: "illegalByteSequence")
  1067. public static var EILSEQ: Errno { illegalByteSequence }
  1068. #if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
  1069. /// Attribute not found.
  1070. ///
  1071. /// The specified extended attribute doesn't exist.
  1072. ///
  1073. /// The corresponding C error is `ENOATTR`.
  1074. @_alwaysEmitIntoClient
  1075. public static var attributeNotFound: Errno { .init(rawValue: _ENOATTR) }
  1076. @_alwaysEmitIntoClient
  1077. @available(*, unavailable, renamed: "attributeNotFound")
  1078. public static var ENOATTR: Errno { attributeNotFound }
  1079. #endif
  1080. #if !os(Windows)
  1081. /// Bad message.
  1082. ///
  1083. /// The message to be received is inappropriate
  1084. /// for the attempted operation.
  1085. ///
  1086. /// The corresponding C error is `EBADMSG`.
  1087. @_alwaysEmitIntoClient
  1088. public static var badMessage: Errno { .init(rawValue: _EBADMSG) }
  1089. @_alwaysEmitIntoClient
  1090. @available(*, unavailable, renamed: "badMessage")
  1091. public static var EBADMSG: Errno { badMessage }
  1092. #if !os(OpenBSD)
  1093. /// Reserved.
  1094. ///
  1095. /// This error is reserved for future use.
  1096. ///
  1097. /// The corresponding C error is `EMULTIHOP`.
  1098. @_alwaysEmitIntoClient
  1099. public static var multiHop: Errno { .init(rawValue: _EMULTIHOP) }
  1100. @_alwaysEmitIntoClient
  1101. @available(*, unavailable, renamed: "multiHop")
  1102. public static var EMULTIHOP: Errno { multiHop }
  1103. #if !os(WASI) && !os(FreeBSD)
  1104. /// No message available.
  1105. ///
  1106. /// No message was available to be received by the requested operation.
  1107. ///
  1108. /// The corresponding C error is `ENODATA`.
  1109. @_alwaysEmitIntoClient
  1110. public static var noData: Errno { .init(rawValue: _ENODATA) }
  1111. @_alwaysEmitIntoClient
  1112. @available(*, unavailable, renamed: "noData")
  1113. public static var ENODATA: Errno { noData }
  1114. #endif
  1115. /// Reserved.
  1116. ///
  1117. /// This error is reserved for future use.
  1118. ///
  1119. /// The corresponding C error is `ENOLINK`.
  1120. @_alwaysEmitIntoClient
  1121. public static var noLink: Errno { .init(rawValue: _ENOLINK) }
  1122. @_alwaysEmitIntoClient
  1123. @available(*, unavailable, renamed: "noLink")
  1124. public static var ENOLINK: Errno { noLink }
  1125. #if !os(WASI) && !os(FreeBSD)
  1126. /// Reserved.
  1127. ///
  1128. /// This error is reserved for future use.
  1129. ///
  1130. /// The corresponding C error is `ENOSR`.
  1131. @_alwaysEmitIntoClient
  1132. public static var noStreamResources: Errno { .init(rawValue: _ENOSR) }
  1133. @_alwaysEmitIntoClient
  1134. @available(*, unavailable, renamed: "noStreamResources")
  1135. public static var ENOSR: Errno { noStreamResources }
  1136. /// Reserved.
  1137. ///
  1138. /// This error is reserved for future use.
  1139. ///
  1140. /// The corresponding C error is `ENOSTR`.
  1141. @_alwaysEmitIntoClient
  1142. public static var notStream: Errno { .init(rawValue: _ENOSTR) }
  1143. @_alwaysEmitIntoClient
  1144. @available(*, unavailable, renamed: "notStream")
  1145. public static var ENOSTR: Errno { notStream }
  1146. #endif
  1147. #endif
  1148. /// Protocol error.
  1149. ///
  1150. /// Some protocol error occurred.
  1151. /// This error is device-specific,
  1152. /// but generally isn't related to a hardware failure.
  1153. ///
  1154. /// The corresponding C error is `EPROTO`.
  1155. @_alwaysEmitIntoClient
  1156. public static var protocolError: Errno { .init(rawValue: _EPROTO) }
  1157. @_alwaysEmitIntoClient
  1158. @available(*, unavailable, renamed: "protocolError")
  1159. public static var EPROTO: Errno { protocolError }
  1160. #if !os(OpenBSD) && !os(WASI) && !os(FreeBSD)
  1161. /// Reserved.
  1162. ///
  1163. /// This error is reserved for future use.
  1164. ///
  1165. /// The corresponding C error is `ETIME`.
  1166. @_alwaysEmitIntoClient
  1167. public static var timeout: Errno { .init(rawValue: _ETIME) }
  1168. @_alwaysEmitIntoClient
  1169. @available(*, unavailable, renamed: "timeout")
  1170. public static var ETIME: Errno { timeout }
  1171. #endif
  1172. #endif
  1173. /// Operation not supported on socket.
  1174. ///
  1175. /// The attempted operation isn't supported for the type of socket referenced;
  1176. /// for example, trying to accept a connection on a datagram socket.
  1177. ///
  1178. /// The corresponding C error is `EOPNOTSUPP`.
  1179. @_alwaysEmitIntoClient
  1180. public static var notSupportedOnSocket: Errno { .init(rawValue: _EOPNOTSUPP) }
  1181. @_alwaysEmitIntoClient
  1182. @available(*, unavailable, renamed: "notSupportedOnSocket")
  1183. public static var EOPNOTSUPP: Errno { notSupportedOnSocket }
  1184. }
  1185. // Constants defined in header but not man page
  1186. @available(System 0.0.1, *)
  1187. extension Errno {
  1188. /// Operation would block.
  1189. ///
  1190. /// The corresponding C error is `EWOULDBLOCK`.
  1191. @_alwaysEmitIntoClient
  1192. public static var wouldBlock: Errno { .init(rawValue: _EWOULDBLOCK) }
  1193. @_alwaysEmitIntoClient
  1194. @available(*, unavailable, renamed: "wouldBlock")
  1195. public static var EWOULDBLOCK: Errno { wouldBlock }
  1196. #if !os(WASI)
  1197. /// Too many references: can't splice.
  1198. ///
  1199. /// The corresponding C error is `ETOOMANYREFS`.
  1200. @_alwaysEmitIntoClient
  1201. public static var tooManyReferences: Errno { .init(rawValue: _ETOOMANYREFS) }
  1202. @_alwaysEmitIntoClient
  1203. @available(*, unavailable, renamed: "tooManyReferences")
  1204. public static var ETOOMANYREFS: Errno { tooManyReferences }
  1205. /// Too many levels of remote in path.
  1206. ///
  1207. /// The corresponding C error is `EREMOTE`.
  1208. @_alwaysEmitIntoClient
  1209. public static var tooManyRemoteLevels: Errno { .init(rawValue: _EREMOTE) }
  1210. @_alwaysEmitIntoClient
  1211. @available(*, unavailable, renamed: "tooManyRemoteLevels")
  1212. public static var EREMOTE: Errno { tooManyRemoteLevels }
  1213. #endif
  1214. #if SYSTEM_PACKAGE_DARWIN
  1215. /// No such policy registered.
  1216. ///
  1217. /// The corresponding C error is `ENOPOLICY`.
  1218. @_alwaysEmitIntoClient
  1219. public static var noSuchPolicy: Errno { .init(rawValue: _ENOPOLICY) }
  1220. @_alwaysEmitIntoClient
  1221. @available(*, unavailable, renamed: "noSuchPolicy")
  1222. public static var ENOPOLICY: Errno { noSuchPolicy }
  1223. #endif
  1224. #if !os(Windows)
  1225. /// State not recoverable.
  1226. ///
  1227. /// The corresponding C error is `ENOTRECOVERABLE`.
  1228. @_alwaysEmitIntoClient
  1229. public static var notRecoverable: Errno { .init(rawValue: _ENOTRECOVERABLE) }
  1230. @_alwaysEmitIntoClient
  1231. @available(*, unavailable, renamed: "notRecoverable")
  1232. public static var ENOTRECOVERABLE: Errno { notRecoverable }
  1233. /// Previous pthread mutex owner died.
  1234. ///
  1235. /// The corresponding C error is `EOWNERDEAD`.
  1236. @_alwaysEmitIntoClient
  1237. public static var previousOwnerDied: Errno { .init(rawValue: _EOWNERDEAD) }
  1238. @_alwaysEmitIntoClient
  1239. @available(*, unavailable, renamed: "previousOwnerDied")
  1240. public static var EOWNERDEAD: Errno { previousOwnerDied }
  1241. #endif
  1242. #if os(FreeBSD)
  1243. /// Capabilities insufficient.
  1244. ///
  1245. /// The corresponding C error is `ENOTCAPABLE`.
  1246. @_alwaysEmitIntoClient
  1247. public static var notCapable: Errno { .init(rawValue: _ENOTCAPABLE) }
  1248. @_alwaysEmitIntoClient
  1249. @available(*, unavailable, renamed: "notCapable")
  1250. public static var ENOTCAPABLE: Errno { notCapable }
  1251. /// Not permitted in capability mode.
  1252. ///
  1253. /// The corresponding C error is `ECAPMODE`.
  1254. @_alwaysEmitIntoClient
  1255. public static var capabilityMode: Errno { .init(rawValue: _ECAPMODE) }
  1256. @_alwaysEmitIntoClient
  1257. @available(*, unavailable, renamed: "capabilityMode")
  1258. public static var ECAPMODE: Errno { capabilityMode }
  1259. /// Integrity check failed.
  1260. ///
  1261. /// The corresponding C error is `EINTEGRITY`.
  1262. @_alwaysEmitIntoClient
  1263. public static var integrityCheckFailed: Errno { .init(rawValue: _EINTEGRITY) }
  1264. @_alwaysEmitIntoClient
  1265. @available(*, unavailable, renamed: "integrityCheckFailed")
  1266. public static var EINTEGRITY: Errno { integrityCheckFailed }
  1267. #endif
  1268. #if SYSTEM_PACKAGE_DARWIN
  1269. /// Interface output queue is full.
  1270. ///
  1271. /// The corresponding C error is `EQFULL`.
  1272. @_alwaysEmitIntoClient
  1273. public static var outputQueueFull: Errno { .init(rawValue: _EQFULL) }
  1274. @_alwaysEmitIntoClient
  1275. @available(*, unavailable, renamed: "outputQueueFull")
  1276. public static var EQFULL: Errno { outputQueueFull }
  1277. #endif
  1278. #if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
  1279. /// The largest valid error.
  1280. ///
  1281. /// This value is the largest valid value
  1282. /// encountered using the C `errno` global variable.
  1283. /// It isn't a valid error.
  1284. ///
  1285. /// The corresponding C error is `ELAST`.
  1286. @_alwaysEmitIntoClient
  1287. public static var lastErrnoValue: Errno { .init(rawValue: _ELAST) }
  1288. @_alwaysEmitIntoClient
  1289. @available(*, unavailable, renamed: "lastErrnoValue")
  1290. public static var ELAST: Errno { lastErrnoValue }
  1291. #endif
  1292. }
  1293. @available(System 0.0.1, *)
  1294. extension Errno {
  1295. // TODO: We want to provide safe access to `errno`, but we need a
  1296. // release-barrier to do so.
  1297. /// The current error value, set by system calls if an error occurs.
  1298. ///
  1299. /// The corresponding C global variable is `errno`.
  1300. internal static var current: Errno {
  1301. get { Errno(rawValue: system_errno) }
  1302. set { system_errno = newValue.rawValue }
  1303. }
  1304. }
  1305. // Use "hidden" entry points for `NSError` bridging
  1306. @available(System 0.0.1, *)
  1307. extension Errno {
  1308. public var _code: Int { Int(rawValue) }
  1309. public var _domain: String { "NSPOSIXErrorDomain" }
  1310. }
  1311. @available(System 0.0.1, *)
  1312. extension Errno: CustomStringConvertible, CustomDebugStringConvertible {
  1313. /// A textual representation of the most recent error
  1314. /// returned by a system call.
  1315. ///
  1316. /// The corresponding C function is `strerror(3)`.
  1317. @inline(never)
  1318. public var description: String {
  1319. guard let ptr = system_strerror(self.rawValue) else { return "unknown error" }
  1320. return String(cString: ptr)
  1321. }
  1322. /// A textual representation,
  1323. /// suitable for debugging,
  1324. /// of the most recent error returned by a system call.
  1325. ///
  1326. /// The corresponding C function is `strerror(3)`.
  1327. public var debugDescription: String { self.description }
  1328. }
  1329. @available(System 0.0.1, *)
  1330. extension Errno {
  1331. @_alwaysEmitIntoClient
  1332. public static func ~=(_ lhs: Errno, _ rhs: Error) -> Bool {
  1333. guard let value = rhs as? Errno else { return false }
  1334. return lhs == value
  1335. }
  1336. }