xge-list.h revision a23fd118e437af0a7877dd313db8fdaa3537c675
a23fd118e437af0a7877dd313db8fdaa3537c675yl * CDDL HEADER START
a23fd118e437af0a7877dd313db8fdaa3537c675yl * The contents of this file are subject to the terms of the
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Common Development and Distribution License (the "License").
a23fd118e437af0a7877dd313db8fdaa3537c675yl * You may not use this file except in compliance with the License.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See the License for the specific language governing permissions
a23fd118e437af0a7877dd313db8fdaa3537c675yl * and limitations under the License.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * When distributing Covered Code, include this CDDL HEADER in each
a23fd118e437af0a7877dd313db8fdaa3537c675yl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * If applicable, add the following below this CDDL HEADER, with the
a23fd118e437af0a7877dd313db8fdaa3537c675yl * fields enclosed by brackets "[]" replaced with your own identifying
a23fd118e437af0a7877dd313db8fdaa3537c675yl * information: Portions Copyright [yyyy] [name of copyright owner]
a23fd118e437af0a7877dd313db8fdaa3537c675yl * CDDL HEADER END
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Copyright (c) 2002-2005 Neterion, Inc.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * All right Reserved.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * FileName : xge-list.h
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Description: Generic bi-directional linked list implementation
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Created: 14 May 2004
a23fd118e437af0a7877dd313db8fdaa3537c675yl * struct xge_list_t - List item.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @prev: Previous list item.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @next: Next list item.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Item of a bi-directional linked list.
a23fd118e437af0a7877dd313db8fdaa3537c675yltypedef struct xge_list_t {
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_list_init - Initialize linked list.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * header: first element of the list (head)
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Initialize linked list.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_list_t{}.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_list_is_empty - Is the list empty?
a23fd118e437af0a7877dd313db8fdaa3537c675yl * header: first element of the list (head)
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Determine whether the bi-directional list is empty. Return '1' in
a23fd118e437af0a7877dd313db8fdaa3537c675yl * case of 'empty'.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_list_t{}.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_list_remove - Remove the specified item from the linked list.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * item: element of the list
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Remove item from a list.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_list_insert(), xge_list_t{}.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_list_insert - Insert a new item after the specified item.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * new_item: new element of the list
a23fd118e437af0a7877dd313db8fdaa3537c675yl * prev_item: element of the list after which the new element is
a23fd118e437af0a7877dd313db8fdaa3537c675yl * inserted
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Insert new item (new_item) after given item (prev_item).
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_list_remove(), xge_list_insert_before(), xge_list_t{}.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_list_insert_before - Insert a new item before the specified item.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * new_item: new element of the list
a23fd118e437af0a7877dd313db8fdaa3537c675yl * next_item: element of the list after which the new element is inserted
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Insert new item (new_item) before given item (next_item).
a23fd118e437af0a7877dd313db8fdaa3537c675ylstatic inline void xge_list_insert_before (xge_list_t *new_item,
a23fd118e437af0a7877dd313db8fdaa3537c675yl for (_p = (_h)->next, xge_os_prefetch(_p->next); _p != (_h); \
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_container_of - Given a member, return the containing structure.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @ptr: the pointer to the member.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @type: the type of the container struct this is embedded in.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @member: the name of the member within the struct.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Cast a member of a structure out to the containing structure.
a23fd118e437af0a7877dd313db8fdaa3537c675yl (type *)(void *)( (char *)__mptr - ((size_t) &((type *)0)->member) );})
a23fd118e437af0a7877dd313db8fdaa3537c675yl/* type unsafe version */
a23fd118e437af0a7877dd313db8fdaa3537c675yl ((type*)(void*)((char*)(ptr) - ((size_t) &((type *)0)->member)))
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_offsetof - Offset of the member in the containing structure.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @t: struct name.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @m: the name of the member within the struct.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Return the offset of the member @m in the structure @t.
a23fd118e437af0a7877dd313db8fdaa3537c675yl#endif /* XGE_LIST_H */