e92e3a8694f157faf8a9e44096a70ada86c556bfzw * drm_linux_list.h -- linux list functions for the BSDs.
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * Created: Mon Apr 7 14:30:16 1999 by anholt@FreeBSD.org
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * Copyright 2003 Eric Anholt
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China * Copyright (c) 2009, Intel Corporation.
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * All Rights Reserved.
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * Permission is hereby granted, free of charge, to any person obtaining a
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * copy of this software and associated documentation files (the "Software"),
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * to deal in the Software without restriction, including without limitation
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * the rights to use, copy, modify, merge, publish, distribute, sublicense,
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * and/or sell copies of the Software, and to permit persons to whom the
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * Software is furnished to do so, subject to the following conditions:
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * The above copyright notice and this permission notice (including the next
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * paragraph) shall be included in all copies or substantial portions of the
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * Software.
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * OTHER DEALINGS IN THE SOFTWARE.
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * Authors:
e92e3a8694f157faf8a9e44096a70ada86c556bfzw * Eric Anholt <anholt@FreeBSD.org>
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China * Use is subject to license terms.
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China caddr_t contain_ptr;
e92e3a8694f157faf8a9e44096a70ada86c556bfzw/* Cheat, assume the list_head is at the start of the struct */
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China#define list_entry(entry, type, member) (type *)(uintptr_t)(entry->contain_ptr)
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China (head)->contain_ptr = (caddr_t)head; \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China#define list_add(entry, head, con_ptr) { \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China (head)->next->prev = entry; \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China (entry)->next = (head)->next; \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China (entry)->prev = head; \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China (head)->next = entry; \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China (entry)->contain_ptr = con_ptr; \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China#define list_add_tail(entry, head, con_ptr) { \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China (entry)->contain_ptr = con_ptr; \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China (entry)->contain_ptr = NULL; \
e92e3a8694f157faf8a9e44096a70ada86c556bfzw for (entry = (head)->next; entry != head; entry = (entry)->next)
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China entry != head; \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China#define list_del_init(entry) { \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China list_del(entry); \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China INIT_LIST_HEAD(entry); \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China#define list_move_tail(entry, head, con_ptr) { \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China list_del(entry); \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China list_add_tail(entry, head, con_ptr); \
0035d21c77a24d02faf34c10aabc120ca692efb5miao chen - Sun Microsystems - Beijing China#define list_empty(head) ((head)->next == head)
e92e3a8694f157faf8a9e44096a70ada86c556bfzw#endif /* _DRM_LINUX_LIST_H_ */