]>
git.saurik.com Git - apple/libc.git/blob - mach/headers/port_obj.h
4c60f6fadf78e7da3e783bb759d34f467ff6ae31
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
30 * Define a service to map from a kernel-generated port name
31 * to server-defined "type" and "value" data to be associated
38 #include <mach/port.h>
40 struct port_obj_tentry
{
45 #include <sys/cdefs.h>
48 extern void port_obj_init(int);
49 extern struct port_obj_tentry
*port_obj_table
;
50 extern int port_obj_table_size
;
53 #ifndef PORT_OBJ_ASSERT
55 #define port_set_obj_value_type(pname, value, type) \
59 if (!port_obj_table) \
60 port_obj_init(port_obj_table_size); \
61 ndx = MACH_PORT_INDEX(pname); \
62 port_obj_table[ndx].pos_value = (value); \
63 port_obj_table[ndx].pos_type = (type); \
66 #define port_get_obj_value(pname) \
67 (port_obj_table[MACH_PORT_INDEX(pname)].pos_value)
69 #define port_get_obj_type(pname) \
70 (port_obj_table[MACH_PORT_INDEX(pname)].pos_type)
72 #else /* PORT_OBJ_ASSERT */
74 #define port_set_obj_value_type(pname, value, type) \
78 if (!port_obj_table) \
79 port_obj_init(port_obj_table_size); \
80 ndx = MACH_PORT_INDEX(pname); \
82 assert(ndx < port_obj_table_size); \
83 port_obj_table[ndx].pos_value = (value); \
84 port_obj_table[ndx].pos_type = (type); \
87 #define port_get_obj_value(pname) \
88 ((MACH_PORT_INDEX(pname) < (unsigned)port_obj_table_size) ? \
89 port_obj_table[MACH_PORT_INDEX(pname)].pos_value : \
90 (panic("port_get_obj_value: index too big"), (void *)-1))
92 #define port_get_obj_type(pname) \
93 ((MACH_PORT_INDEX(pname) < (unsigned)port_obj_table_size) ? \
94 port_obj_table[MACH_PORT_INDEX(pname)].pos_type : \
95 (panic("port_get_obj_type: index too big"), -1))
97 #endif /* PORT_OBJ_ASSERT */
99 #endif /* PORT_OBJ_H */