]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/error.h
xnu-792.6.76.tar.gz
[apple/xnu.git] / osfmk / mach / error.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * @OSF_COPYRIGHT@
24 */
25 /*
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
28 * All Rights Reserved.
29 *
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
35 *
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
39 *
40 * Carnegie Mellon requests users of this software to return to
41 *
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
46 *
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
49 */
50 /*
51 */
52 /*
53 * File: mach/error.h
54 * Purpose:
55 * error module definitions
56 *
57 */
58
59 #ifndef _MACH_ERROR_H_
60 #define _MACH_ERROR_H_
61
62 #include <mach/kern_return.h>
63
64 /*
65 * error number layout as follows:
66 *
67 * hi lo
68 * | system(6) | subsystem(12) | code(14) |
69 */
70
71
72 #define err_none (mach_error_t)0
73 #define ERR_SUCCESS (mach_error_t)0
74 #define ERR_ROUTINE_NIL (mach_error_fn_t)0
75
76
77 #define err_system(x) (((x)&0x3f)<<26)
78 #define err_sub(x) (((x)&0xfff)<<14)
79
80 #define err_get_system(err) (((err)>>26)&0x3f)
81 #define err_get_sub(err) (((err)>>14)&0xfff)
82 #define err_get_code(err) ((err)&0x3fff)
83
84 #define system_emask (err_system(0x3f))
85 #define sub_emask (err_sub(0xfff))
86 #define code_emask (0x3fff)
87
88
89 /* major error systems */
90 #define err_kern err_system(0x0) /* kernel */
91 #define err_us err_system(0x1) /* user space library */
92 #define err_server err_system(0x2) /* user space servers */
93 #define err_ipc err_system(0x3) /* old ipc errors */
94 #define err_mach_ipc err_system(0x4) /* mach-ipc errors */
95 #define err_dipc err_system(0x7) /* distributed ipc */
96 #define err_local err_system(0x3e) /* user defined errors */
97 #define err_ipc_compat err_system(0x3f) /* (compatibility) mach-ipc errors */
98
99 #define err_max_system 0x3f
100
101
102 /* unix errors get lumped into one subsystem */
103 #define unix_err(errno) (err_kern|err_sub(3)|errno)
104
105 typedef kern_return_t mach_error_t;
106 typedef mach_error_t (* mach_error_fn_t)( void );
107
108 #endif /* _MACH_ERROR_H_ */