1/*
2 * Copyright (c) 2000-2012 Apple, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
29/*
30 * Copyright (c) 1982, 1986, 1989, 1993
31 *	The Regents of the University of California.  All rights reserved.
32 * (c) UNIX System Laboratories, Inc.
33 * All or some portions of this file are derived from material licensed
34 * to the University of California by American Telephone and Telegraph
35 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
36 * the permission of UNIX System Laboratories, Inc.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 *    notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 *    notice, this list of conditions and the following disclaimer in the
45 *    documentation and/or other materials provided with the distribution.
46 * 3. All advertising materials mentioning features or use of this software
47 *    must display the following acknowledgement:
48 *	This product includes software developed by the University of
49 *	California, Berkeley and its contributors.
50 * 4. Neither the name of the University nor the names of its contributors
51 *    may be used to endorse or promote products derived from this software
52 *    without specific prior written permission.
53 *
54 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
55 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE.
65 *
66 *	@(#)errno.h	8.5 (Berkeley) 1/21/94
67 */
68
69#ifndef	_SYS_ERRNO_H_
70#define	_SYS_ERRNO_H_
71
72#include <sys/cdefs.h>
73
74#if !defined(KERNEL) && !defined(KERNEL_PRIVATE)
75
76#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
77#include <sys/_types/_errno_t.h>
78#endif
79
80__BEGIN_DECLS
81extern int * __error(void);
82#define errno (*__error())
83__END_DECLS
84#endif
85
86/*
87 * Error codes
88 */
89
90#define	EPERM		1		/* Operation not permitted */
91#define	ENOENT		2		/* No such file or directory */
92#define	ESRCH		3		/* No such process */
93#define	EINTR		4		/* Interrupted system call */
94#define	EIO		5		/* Input/output error */
95#define	ENXIO		6		/* Device not configured */
96#define	E2BIG		7		/* Argument list too long */
97#define	ENOEXEC		8		/* Exec format error */
98#define	EBADF		9		/* Bad file descriptor */
99#define	ECHILD		10		/* No child processes */
100#define	EDEADLK		11		/* Resource deadlock avoided */
101					/* 11 was EAGAIN */
102#define	ENOMEM		12		/* Cannot allocate memory */
103#define	EACCES		13		/* Permission denied */
104#define	EFAULT		14		/* Bad address */
105#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
106#define	ENOTBLK		15		/* Block device required */
107#endif
108#define	EBUSY		16		/* Device / Resource busy */
109#define	EEXIST		17		/* File exists */
110#define	EXDEV		18		/* Cross-device link */
111#define	ENODEV		19		/* Operation not supported by device */
112#define	ENOTDIR		20		/* Not a directory */
113#define	EISDIR		21		/* Is a directory */
114#define	EINVAL		22		/* Invalid argument */
115#define	ENFILE		23		/* Too many open files in system */
116#define	EMFILE		24		/* Too many open files */
117#define	ENOTTY		25		/* Inappropriate ioctl for device */
118#define	ETXTBSY		26		/* Text file busy */
119#define	EFBIG		27		/* File too large */
120#define	ENOSPC		28		/* No space left on device */
121#define	ESPIPE		29		/* Illegal seek */
122#define	EROFS		30		/* Read-only file system */
123#define	EMLINK		31		/* Too many links */
124#define	EPIPE		32		/* Broken pipe */
125
126/* math software */
127#define	EDOM		33		/* Numerical argument out of domain */
128#define	ERANGE		34		/* Result too large */
129
130/* non-blocking and interrupt i/o */
131#define	EAGAIN		35		/* Resource temporarily unavailable */
132#define	EWOULDBLOCK	EAGAIN		/* Operation would block */
133#define	EINPROGRESS	36		/* Operation now in progress */
134#define	EALREADY	37		/* Operation already in progress */
135
136/* ipc/network software -- argument errors */
137#define	ENOTSOCK	38		/* Socket operation on non-socket */
138#define	EDESTADDRREQ	39		/* Destination address required */
139#define	EMSGSIZE	40		/* Message too long */
140#define	EPROTOTYPE	41		/* Protocol wrong type for socket */
141#define	ENOPROTOOPT	42		/* Protocol not available */
142#define	EPROTONOSUPPORT	43		/* Protocol not supported */
143#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
144#define	ESOCKTNOSUPPORT	44		/* Socket type not supported */
145#endif
146#define ENOTSUP		45		/* Operation not supported */
147#if !__DARWIN_UNIX03 && !defined(KERNEL)
148/*
149 * This is the same for binary and source copmpatability, unless compiling
150 * the kernel itself, or compiling __DARWIN_UNIX03; if compiling for the
151 * kernel, the correct value will be returned.  If compiling non-POSIX
152 * source, the kernel return value will be converted by a stub in libc, and
153 * if compiling source with __DARWIN_UNIX03, the conversion in libc is not
154 * done, and the caller gets the expected (discrete) value.
155 */
156#define	EOPNOTSUPP	 ENOTSUP	/* Operation not supported on socket */
157#endif /* !__DARWIN_UNIX03 && !KERNEL */
158
159#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
160#define	EPFNOSUPPORT	46		/* Protocol family not supported */
161#endif
162#define	EAFNOSUPPORT	47		/* Address family not supported by protocol family */
163#define	EADDRINUSE	48		/* Address already in use */
164#define	EADDRNOTAVAIL	49		/* Can't assign requested address */
165
166/* ipc/network software -- operational errors */
167#define	ENETDOWN	50		/* Network is down */
168#define	ENETUNREACH	51		/* Network is unreachable */
169#define	ENETRESET	52		/* Network dropped connection on reset */
170#define	ECONNABORTED	53		/* Software caused connection abort */
171#define	ECONNRESET	54		/* Connection reset by peer */
172#define	ENOBUFS		55		/* No buffer space available */
173#define	EISCONN		56		/* Socket is already connected */
174#define	ENOTCONN	57		/* Socket is not connected */
175#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
176#define	ESHUTDOWN	58		/* Can't send after socket shutdown */
177#define	ETOOMANYREFS	59		/* Too many references: can't splice */
178#endif
179#define	ETIMEDOUT	60		/* Operation timed out */
180#define	ECONNREFUSED	61		/* Connection refused */
181
182#define	ELOOP		62		/* Too many levels of symbolic links */
183#define	ENAMETOOLONG	63		/* File name too long */
184
185/* should be rearranged */
186#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
187#define	EHOSTDOWN	64		/* Host is down */
188#endif
189#define	EHOSTUNREACH	65		/* No route to host */
190#define	ENOTEMPTY	66		/* Directory not empty */
191
192/* quotas & mush */
193#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
194#define	EPROCLIM	67		/* Too many processes */
195#define	EUSERS		68		/* Too many users */
196#endif
197#define	EDQUOT		69		/* Disc quota exceeded */
198
199/* Network File System */
200#define	ESTALE		70		/* Stale NFS file handle */
201#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
202#define	EREMOTE		71		/* Too many levels of remote in path */
203#define	EBADRPC		72		/* RPC struct is bad */
204#define	ERPCMISMATCH	73		/* RPC version wrong */
205#define	EPROGUNAVAIL	74		/* RPC prog. not avail */
206#define	EPROGMISMATCH	75		/* Program version wrong */
207#define	EPROCUNAVAIL	76		/* Bad procedure for program */
208#endif
209
210#define	ENOLCK		77		/* No locks available */
211#define	ENOSYS		78		/* Function not implemented */
212
213#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
214#define	EFTYPE		79		/* Inappropriate file type or format */
215#define	EAUTH		80		/* Authentication error */
216#define	ENEEDAUTH	81		/* Need authenticator */
217
218/* Intelligent device errors */
219#define	EPWROFF		82	/* Device power is off */
220#define	EDEVERR		83	/* Device error, e.g. paper out */
221#endif
222
223#define	EOVERFLOW	84		/* Value too large to be stored in data type */
224
225/* Program loading errors */
226#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
227#define EBADEXEC	85	/* Bad executable */
228#define EBADARCH	86	/* Bad CPU type in executable */
229#define ESHLIBVERS	87	/* Shared library version mismatch */
230#define EBADMACHO	88	/* Malformed Macho file */
231#endif
232
233#define	ECANCELED	89		/* Operation canceled */
234
235#define EIDRM		90		/* Identifier removed */
236#define ENOMSG		91		/* No message of desired type */
237#define EILSEQ		92		/* Illegal byte sequence */
238#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
239#define ENOATTR		93		/* Attribute not found */
240#endif
241
242#define EBADMSG		94		/* Bad message */
243#define EMULTIHOP	95		/* Reserved */
244#define	ENODATA		96		/* No message available on STREAM */
245#define ENOLINK		97		/* Reserved */
246#define ENOSR		98		/* No STREAM resources */
247#define ENOSTR		99		/* Not a STREAM */
248#define	EPROTO		100		/* Protocol error */
249#define ETIME		101		/* STREAM ioctl timeout */
250
251#if __DARWIN_UNIX03 || defined(KERNEL)
252/* This value is only discrete when compiling __DARWIN_UNIX03, or KERNEL */
253#define	EOPNOTSUPP	102		/* Operation not supported on socket */
254#endif /* __DARWIN_UNIX03 || KERNEL */
255
256#define ENOPOLICY	103		/* No such policy registered */
257
258#if __DARWIN_C_LEVEL >= 200809L
259#define ENOTRECOVERABLE 104		/* State not recoverable */
260#define EOWNERDEAD      105		/* Previous owner died */
261#endif
262
263#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
264#define	EQFULL		106		/* Interface output queue is full */
265#define	ELAST		106		/* Must be equal largest errno */
266#endif
267
268#ifdef KERNEL
269/* pseudo-errors returned inside kernel to modify return to process */
270#define	ERESTART	(-1)		/* restart syscall */
271#define	EJUSTRETURN	(-2)		/* don't modify regs, just return */
272
273#ifdef BSD_KERNEL_PRIVATE
274#define ERECYCLE    (-5)		/* restart lookup under heavy vnode pressure/recycling */
275#define EREDRIVEOPEN	(-6)
276#define EKEEPLOOKING	(-7)
277#define ERESERVEDNAME	(-8)		/* path is known but not usable */
278/* used for cvwait error returns to Libc */
279#define ECVCERORR	256
280#define ECVPERORR	512
281#else /* BSD_KERNEL_PRIVATE */
282/* -5, -6 and -7 and -106 are reserved for kernel internal use */
283#endif /* BSD_KERNEL_PRIVATE */
284#ifdef PRIVATE
285#define	EQSUSPENDED	(-EQFULL)	/* Output queue is suspended */
286#endif /* PRIVATE */
287#endif /* KERNEL */
288#endif /* _SYS_ERRNO_H_ */
289