9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER START
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * The contents of this file are subject to the terms of the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Common Development and Distribution License (the "License").
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You may not use this file except in compliance with the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * See the License for the specific language governing permissions
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * and limitations under the License.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * When distributing Covered Code, include this CDDL HEADER in each
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * If applicable, add the following below this CDDL HEADER, with the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * fields enclosed by brackets "[]" replaced with your own identifying
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * information: Portions Copyright [yyyy] [name of copyright owner]
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * CDDL HEADER END
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Use is subject to license terms.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * PURPOSE: Manage doubly linked lists within the DAPL Reference Implementation
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * A link list head points to the first member of a linked list, but
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * is itself not a member of the list.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * +---------------------------------------------+
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * | entry entry entry |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * HEAD -> | +-------+ +-------+ +-------+ |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * +--> | flink | --> | flink | --> | flink | >--+
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * | data | | data | | data |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * +--< | blink | <-- | blink | <-- | blink | <--|
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * | +-------+ +-------+ +-------+ |
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * +---------------------------------------------+
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Note: Each of the remove functions takes an assertion failure if
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * an element cannot be removed from the list.
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * $Id: dapl_llist.c,v 1.9 2003/06/13 12:21:11 sjs2 Exp $
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_llist_init_head()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Purpose: initialize a linked list head
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_llist_init_entry()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Purpose: initialize a linked list entry
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_llist_is_empty()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Purpose: returns TRUE if the linked list is empty
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_llist_add_head()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Purpose: Add an entry to the head of a linked list
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* deal with empty list */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_llist_add_tail()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Purpose: Add an entry to the tail of a linked list
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* deal with empty list */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_llist_add_entry()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Purpose: Add an entry before an element in the list
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* deal with empty list */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_llist_remove_head()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Purpose: Remove the first entry of a linked list
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* clean up the links for good measure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_llist_remove_tail()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Purpose: Remove the last entry of a linked list
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* clean up the links for good measure */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_llist_remove_entry()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Purpose: Remove the specified entry from a linked list
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylordapl_llist_remove_entry(DAPL_LLIST_HEAD *head, DAPL_LLIST_ENTRY *entry)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* if it's the first entry, pull it off */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor /* if it was the only entry, kill the list */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * not finding the element on the list
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * is a BAD thing
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor#endif /* VERIFY_LINKED_LIST */
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_llist_peek_head
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_llist_next_entry
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Obtain the next entry in the list, return NULL when we get to the
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * dapl_llist_debug_print_list()
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor * Purpose: Prints the linked list for debugging
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylordapl_llist_debug_print_list(DAPL_LLIST_HEAD *head)
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor dapl_dbg_log(DAPL_DBG_TYPE_RTN, "EMPTY_LIST\n");
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor dapl_dbg_log(DAPL_DBG_TYPE_RTN, "HEAD %p\n", *head);
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor dapl_dbg_log(DAPL_DBG_TYPE_RTN, "Entry %p %p %p %p\n",
9e39c5ba00a55fa05777cc94b148296af305e135Bill Taylor dapl_dbg_log(DAPL_DBG_TYPE_RTN, "Entry %p %p %p %p\n",