Annotation of kernel/ipc/ipc_table.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
        !             7:  * Reserved.  This file contains Original Code and/or Modifications of
        !             8:  * Original Code as defined in and that are subject to the Apple Public
        !             9:  * Source License Version 1.1 (the "License").  You may not use this file
        !            10:  * except in compliance with the License.  Please obtain a copy of the
        !            11:  * License at http://www.apple.com/publicsource and read it before using
        !            12:  * this file.
        !            13:  * 
        !            14:  * The Original Code and all software distributed under the License are
        !            15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            19:  * License for the specific language governing rights and limitations
        !            20:  * under the License.
        !            21:  * 
        !            22:  * @APPLE_LICENSE_HEADER_END@
        !            23:  */
        !            24: 
        !            25: /*
        !            26:  * Copyright (c) 1995, 1994, 1993, 1992, 1991, 1990  
        !            27:  * Open Software Foundation, Inc. 
        !            28:  *  
        !            29:  * Permission to use, copy, modify, and distribute this software and 
        !            30:  * its documentation for any purpose and without fee is hereby granted, 
        !            31:  * provided that the above copyright notice appears in all copies and 
        !            32:  * that both the copyright notice and this permission notice appear in 
        !            33:  * supporting documentation, and that the name of ("OSF") or Open Software 
        !            34:  * Foundation not be used in advertising or publicity pertaining to 
        !            35:  * distribution of the software without specific, written prior permission. 
        !            36:  *  
        !            37:  * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE 
        !            38:  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
        !            39:  * FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL OSF BE LIABLE FOR ANY 
        !            40:  * SPECIAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 
        !            41:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 
        !            42:  * ACTION OF CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING 
        !            43:  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE 
        !            44:  */
        !            45: /*
        !            46:  * OSF Research Institute MK6.1 (unencumbered) 1/31/1995
        !            47:  */
        !            48: /* 
        !            49:  * Mach Operating System
        !            50:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
        !            51:  * All Rights Reserved.
        !            52:  * 
        !            53:  * Permission to use, copy, modify and distribute this software and its
        !            54:  * documentation is hereby granted, provided that both the copyright
        !            55:  * notice and this permission notice appear in all copies of the
        !            56:  * software, derivative works or modified versions, and any portions
        !            57:  * thereof, and that both notices appear in supporting documentation.
        !            58:  * 
        !            59:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            60:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            61:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            62:  * 
        !            63:  * Carnegie Mellon requests users of this software to return to
        !            64:  * 
        !            65:  *  Software Distribution Coordinator  or  [email protected]
        !            66:  *  School of Computer Science
        !            67:  *  Carnegie Mellon University
        !            68:  *  Pittsburgh PA 15213-3890
        !            69:  * 
        !            70:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            71:  * the rights to redistribute these changes.
        !            72:  */
        !            73: /*
        !            74:  *     File:   ipc/ipc_table.h
        !            75:  *     Author: Rich Draves
        !            76:  *     Date:   1989
        !            77:  *
        !            78:  *     Definitions for tables, used for IPC capabilities (ipc_entry_t)
        !            79:  *     and dead-name requests (ipc_port_request_t).
        !            80:  */
        !            81: 
        !            82: #ifndef        _IPC_IPC_TABLE_H_
        !            83: #define        _IPC_IPC_TABLE_H_
        !            84: 
        !            85: #include <mach/boolean.h>
        !            86: #include <mach/vm_param.h>
        !            87: 
        !            88: /*
        !            89:  *     The is_table_next field of an ipc_space_t points to
        !            90:  *     an ipc_table_size structure.  These structures must
        !            91:  *     be elements of an array, ipc_table_entries.
        !            92:  *
        !            93:  *     The array must end with two elements with the same its_size value.
        !            94:  *     Except for the terminating element, the its_size values must
        !            95:  *     be strictly increasing.  The largest (last) its_size value
        !            96:  *     must be less than or equal to MACH_PORT_INDEX(MACH_PORT_DEAD).
        !            97:  *     This ensures that
        !            98:  *             1) MACH_PORT_INDEX(MACH_PORT_DEAD) isn't a valid index
        !            99:  *             in the table, so ipc_entry_get won't allocate it.
        !           100:  *             2) MACH_PORT_MAKE(index+1, 0) and MAKE_PORT_MAKE(size, 0)
        !           101:  *             won't ever overflow.
        !           102:  *
        !           103:  *
        !           104:  *     The ipr_size field of the first element in a table of
        !           105:  *     dead-name requests (ipc_port_request_t) points to the
        !           106:  *     ipc_table_size structure.  The structures must be elements
        !           107:  *     of ipc_table_dnrequests.  ipc_table_dnrequests must end
        !           108:  *     with an element with zero its_size, and except for this last
        !           109:  *     element, the its_size values must be strictly increasing.
        !           110:  *
        !           111:  *     The is_table_next field points to the ipc_table_size structure
        !           112:  *     for the next larger size of table, not the one currently in use.
        !           113:  *     The ipr_size field points to the currently used ipc_table_size.
        !           114:  */
        !           115: 
        !           116: typedef unsigned int ipc_table_index_t;        /* index into tables */
        !           117: typedef unsigned int ipc_table_elems_t;        /* size of tables */
        !           118: 
        !           119: typedef struct ipc_table_size {
        !           120:        ipc_table_elems_t its_size;     /* number of elements in table */
        !           121: } *ipc_table_size_t;
        !           122: 
        !           123: #define        ITS_NULL        ((ipc_table_size_t) 0)
        !           124: #define ITS_SIZE_NONE  -1
        !           125: 
        !           126: extern ipc_table_size_t ipc_table_entries;
        !           127: extern ipc_table_size_t ipc_table_dnrequests;
        !           128: 
        !           129: /* Initialize IPC capabilities table storage */
        !           130: extern void ipc_table_init(void);
        !           131: 
        !           132: /*
        !           133:  *     Note that ipc_table_alloc, ipc_table_realloc, and ipc_table_free
        !           134:  *     all potentially use the VM system.  Hence simple locks can't
        !           135:  *     be held across them.
        !           136:  *
        !           137:  *     We can't use a copying realloc, because the realloc happens
        !           138:  *     with the data unlocked.  ipc_table_realloc remaps the data,
        !           139:  *     so it is OK.
        !           140:  */
        !           141: 
        !           142: /* Allocate a table */
        !           143: extern vm_offset_t ipc_table_alloc(
        !           144:        vm_size_t       size);
        !           145: 
        !           146: /* Reallocate a big table */
        !           147: extern vm_offset_t ipc_table_realloc(
        !           148:        vm_size_t       old_size,
        !           149:        vm_offset_t     old_table,
        !           150:        vm_size_t       new_size);
        !           151: 
        !           152: /* Free a table */
        !           153: extern void ipc_table_free(
        !           154:        vm_size_t       size,
        !           155:        vm_offset_t     table);
        !           156: 
        !           157: #define        it_entries_alloc(its)                                           \
        !           158:        ((ipc_entry_t)                                                  \
        !           159:         ipc_table_alloc((its)->its_size * sizeof(struct ipc_entry)))
        !           160: 
        !           161: #define it_entries_reallocable(its)                                    \
        !           162:        (((its)->its_size * sizeof(struct ipc_entry)) >= PAGE_SIZE)
        !           163: 
        !           164: #define        it_entries_realloc(its, table, nits)                            \
        !           165:        ((ipc_entry_t)                                                  \
        !           166:         ipc_table_realloc((its)->its_size * sizeof(struct ipc_entry),  \
        !           167:                           (vm_offset_t)(table),                        \
        !           168:                           (nits)->its_size * sizeof(struct ipc_entry)))
        !           169: 
        !           170: #define        it_entries_free(its, table)                                     \
        !           171:        ipc_table_free((its)->its_size * sizeof(struct ipc_entry),      \
        !           172:                       (vm_offset_t)(table))
        !           173: 
        !           174: #define        it_dnrequests_alloc(its)                                        \
        !           175:        ((ipc_port_request_t)                                           \
        !           176:         ipc_table_alloc((its)->its_size *                              \
        !           177:                         sizeof(struct ipc_port_request)))
        !           178: 
        !           179: #define        it_dnrequests_free(its, table)                                  \
        !           180:        ipc_table_free((its)->its_size *                                \
        !           181:                       sizeof(struct ipc_port_request),                 \
        !           182:                       (vm_offset_t)(table))
        !           183: 
        !           184: #endif /* _IPC_IPC_TABLE_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.