The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/hpt27xx/list.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2011 HighPoint Technologies, Inc.
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD$
   27  */
   28 
   29 #include <dev/hpt27xx/hpt27xx_config.h>
   30 
   31 #ifndef _HPT_LIST_H_
   32 #define _HPT_LIST_H_
   33 
   34 #ifndef _LINUX_LIST_H
   35 
   36 #ifndef HPT_INLINE
   37 #define HPT_INLINE __inline
   38 #endif
   39 
   40 struct list_head {
   41         struct list_head *next, *prev;
   42 };
   43 
   44 #define INIT_LIST_HEAD(ptr) do { (ptr)->next = (ptr); (ptr)->prev = (ptr); } while (0)
   45 
   46 static HPT_INLINE void __list_add(struct list_head * _new, struct list_head * prev, struct list_head * next)
   47 {
   48         next->prev = _new;
   49         _new->next = next;
   50         _new->prev = prev;
   51         prev->next = _new;
   52 }
   53 
   54 static HPT_INLINE void list_add(struct list_head *_new, struct list_head *head)
   55 {
   56         __list_add(_new, head, head->next);
   57 }
   58 
   59 static HPT_INLINE void list_add_tail(struct list_head *_new, struct list_head *head)
   60 {
   61         __list_add(_new, head->prev, head);
   62 }
   63 
   64 static HPT_INLINE void __list_del(struct list_head * prev, struct list_head * next)
   65 {
   66         next->prev = prev;
   67         prev->next = next;
   68 }
   69 
   70 static HPT_INLINE void list_del(struct list_head *entry)
   71 {
   72         __list_del(entry->prev, entry->next);
   73 }
   74 
   75 static HPT_INLINE void list_del_init(struct list_head *entry)
   76 {
   77         __list_del(entry->prev, entry->next);
   78         INIT_LIST_HEAD(entry); 
   79 }
   80 
   81 static HPT_INLINE int list_empty(struct list_head *head)
   82 {
   83         HPT_ASSERT(!(head->next==head && head->prev!=head));
   84         return head->next == head;
   85 }
   86 
   87 static HPT_INLINE void __list_splice(struct list_head *list,
   88                                  struct list_head *head)
   89 {
   90         struct list_head *first = list->next;
   91         struct list_head *last = list->prev;
   92         struct list_head *at = head->next;
   93 
   94         first->prev = head;
   95         head->next = first;
   96 
   97         last->next = at;
   98         at->prev = last;
   99 }
  100 
  101 static HPT_INLINE void list_splice(struct list_head *list, struct list_head *head)
  102 {
  103         if (!list_empty(list))
  104                 __list_splice(list, head);
  105 }
  106 
  107 static HPT_INLINE void list_splice_init(struct list_head *list, struct list_head *head)
  108 {
  109         if (!list_empty(list)) {
  110                 __list_splice(list, head);
  111                 INIT_LIST_HEAD(list);
  112         }
  113 }
  114 
  115 #define list_entry(ptr, type, member) \
  116         ((type *)((char *)(ptr)-(HPT_UPTR)(&((type *)0)->member)))
  117 
  118 #define list_for_each(pos, head) \
  119         for (pos = (head)->next; pos != (head); pos = pos->next)
  120 
  121 #define list_for_each_safe(pos, n, head) \
  122         for (pos = (head)->next, n = pos->next; pos != (head); \
  123                 pos = n, n = pos->next)
  124 
  125 #define get_first_item(attached, type, member) \
  126         ((type *)((char *)((attached)->next)-(HPT_UPTR)(&((type *)0)->member)))
  127 
  128 #endif
  129 
  130 #endif

Cache object: 9a24a829791ea11126d33effe72d6207


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.