XenevaOS
Loading...
Searching...
No Matches
errno.h
Go to the documentation of this file.
1#ifndef __LINUX_ERRNO_H__
2#define __LINUX_ERRNO_H__
3
4/*
5 * DCL <linux/errno.h> -- the numbers a ported file returns.
6 *
7 * <linux/kernel.h> owns the bulk of the set (EPERM through the socket
8 * errnos), and it is kept as the owner rather than split across two headers
9 * that could drift apart. Everything below is here because a file in the
10 * staged tty/serial set asks for it and kernel.h did not have it:
11 *
12 * EBADF / EINTR / ENOTTY -- tty_io.c's read/write/ioctl error paths
13 * ENOIOCTLCMD -- the tty layer's "this ldisc does not do
14 * ioctls" answer (mainline: 515)
15 * EINPROGRESS -- n_tty's poll path
16 * EFAULT / EACCES / EPIPE ...-- the usual open/write failures
17 *
18 * All guarded, so <linux/mm.h> (which also defines EFAULT and EFBIG) and
19 * kernel.h can be included in any order without a redefinition.
20 *
21 * ERESTARTSYS lives in kernel.h's errno block -- 512, matching mm.h -- because
22 * serial_core.c:1144's scoped_cond_guard() needs it from <linux/mutex.h>
23 * alone.
24 *
25 * The IS_ERR/ERR_PTR family is *not* here; it is in <linux/err.h>, because
26 * mainline splits them that way and a ported file includes <linux/err.h> by
27 * name.
28 */
29
30/*
31 * The two #includes are at the *bottom* of this file, below the table, and
32 * that is load-bearing rather than a style preference.
33 *
34 * drm_rect.c:24 includes <linux/errno.h> as its first include. This header's
35 * guard is set at line 2, and the includes used to follow at line 30 -- which
36 * meant <linux/kernel.h> was pulled in from *inside* this file's own pass.
37 * kernel.h's subtree runs on through virtio.h to <linux/kstrtox.h> (kernel.h:
38 * 234), and kstrtox.h:31 includes <linux/errno.h> in its turn, finds the
39 * guard already set, and takes the no-op. So kstrtox.h is parsed here, before
40 * this file's line 76 has run, and its `return -ERANGE;` at :69 reports
41 * "use of undeclared identifier 'ERANGE'".
42 *
43 * Nothing is #undef'd and the macro is defined by the time the TU finishes --
44 * it is simply not defined yet at the one moment it is read. Moving the
45 * includes below the table closes the loop without changing a single number:
46 * every entry is a literal, and the #ifndef guards around them are what make
47 * the table reconcilable with kernel.h's set in either order, so nothing in
48 * it depends on the includes having happened first.
49 *
50 * One entry does name a symbol from the other header -- EWOULDBLOCK is
51 * EAGAIN, which is kernel.h's -- and it is still safe below, because an
52 * object-like macro is expanded where it is *used*, not where it is defined:
53 * kernel.h has finished by the time any source can read EWOULDBLOCK.
54 */
55#ifndef EINTR
56#define EINTR 4
57#endif
58#ifndef EBADF
59#define EBADF 9
60#endif
61#ifndef ECHILD
62#define ECHILD 10
63#endif
64#ifndef ESRCH
65#define ESRCH 3
66#endif
67#ifndef EACCES
68#define EACCES 13
69#endif
70#ifndef EFAULT
71#define EFAULT 14
72#endif
73#ifndef ENOTBLK
74#define ENOTBLK 15
75#endif
76#ifndef EEXIST
77#define EEXIST 17
78#endif
79#ifndef EXDEV
80#define EXDEV 18
81#endif
82#ifndef ENOTTY
83#define ENOTTY 25
84#endif
85#ifndef ESPIPE
86#define ESPIPE 29
87#endif
88#ifndef EROFS
89#define EROFS 30
90#endif
91#ifndef EPIPE
92#define EPIPE 32
93#endif
94#ifndef EMLINK
95#define EMLINK 31
96#endif
97#ifndef ERANGE
98#define ERANGE 34
99#endif
100#ifndef EINPROGRESS
101#define EINPROGRESS 115
102#endif
103#ifndef EALREADY
104#define EALREADY 114
105#endif
106#ifndef ENOTCONN
107#define ENOTCONN 107
108#endif
109#ifndef ETIMEDOUT
110#define ETIMEDOUT 110
111#endif
112#ifndef EOPNOTSUPP
113#define EOPNOTSUPP 95
114#endif
115#ifndef EWOULDBLOCK
116#define EWOULDBLOCK EAGAIN
117#endif
118
119/*
120 * ENOIOCTLCMD is a tty-layer convention rather than a POSIX errno: the ldisc
121 * answers it to mean "I do not implement this ioctl", and tty_ioctl() then
122 * hands the number on to the driver. It has to sit outside the errno table
123 * proper (mainline puts it at 515, past MAX_ERRNO's useful range is fine
124 * since it never crosses the IS_ERR boundary as a real error).
125 */
126#ifndef ENOIOCTLCMD
127#define ENOIOCTLCMD 515
128#endif
129
130/*
131 * The table is above and the headers it reconciles with are below: kernel.h
132 * owns EPERM through the socket errnos, err.h the IS_ERR/ERR_PTR family.
133 * The reason they come after rather than before is at the top of the file.
134 */
135#include <linux/kernel.h> /* EPERM, EIO, EAGAIN, EINVAL, ... */
136#include <linux/err.h>
137
138#endif /* __LINUX_ERRNO_H__ */