Annotation of OSKit-Mach/ipc/ipc_table.h, revision 1.1

1.1     ! root        1: /* 
        !             2:  * Mach Operating System
        !             3:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
        !             4:  * All Rights Reserved.
        !             5:  * 
        !             6:  * Permission to use, copy, modify and distribute this software and its
        !             7:  * documentation is hereby granted, provided that both the copyright
        !             8:  * notice and this permission notice appear in all copies of the
        !             9:  * software, derivative works or modified versions, and any portions
        !            10:  * thereof, and that both notices appear in supporting documentation.
        !            11:  * 
        !            12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            15:  * 
        !            16:  * Carnegie Mellon requests users of this software to return to
        !            17:  * 
        !            18:  *  Software Distribution Coordinator  or  [email protected]
        !            19:  *  School of Computer Science
        !            20:  *  Carnegie Mellon University
        !            21:  *  Pittsburgh PA 15213-3890
        !            22:  * 
        !            23:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            24:  * the rights to redistribute these changes.
        !            25:  */
        !            26: /*
        !            27:  */
        !            28: /*
        !            29:  *     File:   ipc/ipc_table.h
        !            30:  *     Author: Rich Draves
        !            31:  *     Date:   1989
        !            32:  *
        !            33:  *     Definitions for tables, used for IPC capabilities (ipc_entry_t)
        !            34:  *     and dead-name requests (ipc_port_request_t).
        !            35:  */
        !            36: 
        !            37: #ifndef        _IPC_IPC_TABLE_H_
        !            38: #define        _IPC_IPC_TABLE_H_
        !            39: 
        !            40: #include <mach/boolean.h>
        !            41: #include <mach/vm_param.h>
        !            42: 
        !            43: /*
        !            44:  *     The is_table_next field of an ipc_space_t points to
        !            45:  *     an ipc_table_size structure.  These structures must
        !            46:  *     be elements of an array, ipc_table_entries.
        !            47:  *
        !            48:  *     The array must end with two elements with the same its_size value.
        !            49:  *     Except for the terminating element, the its_size values must
        !            50:  *     be strictly increasing.  The largest (last) its_size value
        !            51:  *     must be less than or equal to MACH_PORT_INDEX(MACH_PORT_DEAD).
        !            52:  *     This ensures that
        !            53:  *             1) MACH_PORT_INDEX(MACH_PORT_DEAD) isn't a valid index
        !            54:  *             in the table, so ipc_entry_get won't allocate it.
        !            55:  *             2) MACH_PORT_MAKE(index+1, 0) and MAKE_PORT_MAKE(size, 0)
        !            56:  *             won't ever overflow.
        !            57:  *
        !            58:  *
        !            59:  *     The ipr_size field of the first element in a table of
        !            60:  *     dead-name requests (ipc_port_request_t) points to the
        !            61:  *     ipc_table_size structure.  The structures must be elements
        !            62:  *     of ipc_table_dnrequests.  ipc_table_dnrequests must end
        !            63:  *     with an element with zero its_size, and except for this last
        !            64:  *     element, the its_size values must be strictly increasing.
        !            65:  *
        !            66:  *     The is_table_next field points to the ipc_table_size structure
        !            67:  *     for the next larger size of table, not the one currently in use.
        !            68:  *     The ipr_size field points to the currently used ipc_table_size.
        !            69:  */
        !            70: 
        !            71: typedef unsigned int ipc_table_index_t;        /* index into tables */
        !            72: typedef unsigned int ipc_table_elems_t;        /* size of tables */
        !            73: 
        !            74: typedef struct ipc_table_size {
        !            75:        ipc_table_elems_t its_size;     /* number of elements in table */
        !            76: } *ipc_table_size_t;
        !            77: 
        !            78: #define        ITS_NULL        ((ipc_table_size_t) 0)
        !            79: 
        !            80: extern ipc_table_size_t ipc_table_entries;
        !            81: extern ipc_table_size_t ipc_table_dnrequests;
        !            82: 
        !            83: extern void
        !            84: ipc_table_init();
        !            85: 
        !            86: /*
        !            87:  *     Note that ipc_table_alloc, ipc_table_realloc, and ipc_table_free
        !            88:  *     all potentially use the VM system.  Hence simple locks can't
        !            89:  *     be held across them.
        !            90:  *
        !            91:  *     We can't use a copying realloc, because the realloc happens
        !            92:  *     with the data unlocked.  ipc_table_realloc remaps the data,
        !            93:  *     so it is OK.
        !            94:  */
        !            95: 
        !            96: /* Allocate a table */
        !            97: extern vm_offset_t ipc_table_alloc(
        !            98:        vm_size_t       size);
        !            99: 
        !           100: /* Reallocate a big table */
        !           101: extern vm_offset_t ipc_table_realloc(
        !           102:        vm_size_t       old_size,
        !           103:        vm_offset_t     old_table,
        !           104:        vm_size_t       new_size);
        !           105: 
        !           106: /* Free a table */
        !           107: extern void ipc_table_free(
        !           108:        vm_size_t       size,
        !           109:        vm_offset_t     table);
        !           110: 
        !           111: #define        it_entries_alloc(its)                                           \
        !           112:        ((ipc_entry_t)                                                  \
        !           113:         ipc_table_alloc((its)->its_size * sizeof(struct ipc_entry)))
        !           114: 
        !           115: #define it_entries_reallocable(its)                                    \
        !           116:        (((its)->its_size * sizeof(struct ipc_entry)) >= PAGE_SIZE)
        !           117: 
        !           118: #define        it_entries_realloc(its, table, nits)                            \
        !           119:        ((ipc_entry_t)                                                  \
        !           120:         ipc_table_realloc((its)->its_size * sizeof(struct ipc_entry),  \
        !           121:                           (vm_offset_t)(table),                        \
        !           122:                           (nits)->its_size * sizeof(struct ipc_entry)))
        !           123: 
        !           124: #define        it_entries_free(its, table)                                     \
        !           125:        ipc_table_free((its)->its_size * sizeof(struct ipc_entry),      \
        !           126:                       (vm_offset_t)(table))
        !           127: 
        !           128: #define        it_dnrequests_alloc(its)                                        \
        !           129:        ((ipc_port_request_t)                                           \
        !           130:         ipc_table_alloc((its)->its_size *                              \
        !           131:                         sizeof(struct ipc_port_request)))
        !           132: 
        !           133: #define        it_dnrequests_free(its, table)                                  \
        !           134:        ipc_table_free((its)->its_size *                                \
        !           135:                       sizeof(struct ipc_port_request),                 \
        !           136:                       (vm_offset_t)(table))
        !           137: 
        !           138: #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.