kern_return_t ipc_space_create( ipc_table_size_t initial, ipc_space_t *spacep) { ipc_space_t space; ipc_entry_t table; ipc_entry_num_t new_size; mach_port_index_t index; space = is_alloc(); if (space == IS_NULL) return KERN_RESOURCE_SHORTAGE; table = it_entries_alloc(initial); if (table == IE_NULL) { is_free(space); return KERN_RESOURCE_SHORTAGE; } new_size = initial->its_size; memset((void *) table, 0, new_size * sizeof(struct ipc_entry)); /* * Initialize the free list in the table. * Add the entries in reverse order, and * set the generation number to -1, so that * initial allocations produce "natural" names. */ for (index = 0; index < new_size; index++) { ipc_entry_t entry = &table[index]; entry->ie_bits = IE_BITS_GEN_MASK; entry->ie_next = index+1; } table[new_size-1].ie_next = 0; is_ref_lock_init(space); space->is_references = 2; is_lock_init(space); space->is_active = TRUE; space->is_growing = FALSE; space->is_table = table; space->is_table_size = new_size; space->is_table_next = initial+1; ipc_splay_tree_init(&space->is_tree); space->is_tree_total = 0; space->is_tree_small = 0; space->is_tree_hash = 0; *spacep = space; return KERN_SUCCESS; }
kern_return_t ipc_space_create_special( ipc_space_t *spacep) { ipc_space_t space; space = is_alloc(); if (space == IS_NULL) return KERN_RESOURCE_SHORTAGE; is_ref_lock_init(space); space->is_references = 1; is_lock_init(space); space->is_active = FALSE; *spacep = space; return KERN_SUCCESS; }
kern_return_t ipc_space_create_special( ipc_space_t *spacep) { ipc_space_t space; space = is_alloc(); if (space == IS_NULL) return KERN_RESOURCE_SHORTAGE; is_lock_init(space); space->is_bits = IS_INACTIVE | 1; /* 1 ref, not active, not growing */ space->is_table = IE_NULL; space->is_task = TASK_NULL; space->is_table_next = 0; space->is_low_mod = 0; space->is_high_mod = 0; *spacep = space; return KERN_SUCCESS; }