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/kern/queue.c

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  * Mach Operating System
    3  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * HISTORY
   28  * $Log:        queue.c,v $
   29  * Revision 2.8  93/03/09  10:55:20  danner
   30  *      Fixed remque not to typecast. ANSI C.
   31  *      [93/03/05            af]
   32  * 
   33  * Revision 2.7  93/01/27  09:35:03  danner
   34  *      Remove ifdef sun around insque and remque.
   35  *      [93/01/25            danner]
   36  * 
   37  * Revision 2.6  92/08/03  17:38:50  jfriedl
   38  *      removed silly prototypes
   39  *      [92/08/02            jfriedl]
   40  * 
   41  * Revision 2.5  92/05/21  17:15:19  jfriedl
   42  *      Added void to fcns that still needed it.
   43  *      [92/05/20            jfriedl]
   44  * 
   45  * Revision 2.4  91/05/14  16:45:45  mrt
   46  *      Correcting copyright
   47  * 
   48  * Revision 2.3  91/05/08  12:48:22  dbg
   49  *      Compile queue routines on vax.
   50  *      [91/03/26            dbg]
   51  * 
   52  * Revision 2.2  91/02/05  17:28:38  mrt
   53  *      Changed to new Mach copyright
   54  *      [91/02/01  16:16:22  mrt]
   55  * 
   56  * Revision 2.1  89/08/03  15:51:47  rwd
   57  * Created.
   58  * 
   59  * 17-Mar-87  David Golub (dbg) at Carnegie-Mellon University
   60  *      Created from routines written by David L. Black.
   61  *
   62  */ 
   63 
   64 /*
   65  *      Routines to implement queue package.
   66  */
   67 
   68 #include <kern/queue.h>
   69 
   70 
   71 
   72 /*
   73  *      Insert element at head of queue.
   74  */
   75 void enqueue_head(
   76         register queue_t        que,
   77         register queue_entry_t  elt)
   78 {
   79         elt->next = que->next;
   80         elt->prev = que;
   81         elt->next->prev = elt;
   82         que->next = elt;
   83 }
   84 
   85 /*
   86  *      Insert element at tail of queue.
   87  */
   88 void enqueue_tail(
   89         register queue_t        que,
   90         register queue_entry_t  elt)
   91 {
   92         elt->next = que;
   93         elt->prev = que->prev;
   94         elt->prev->next = elt;
   95         que->prev = elt;
   96 }
   97 
   98 /*
   99  *      Remove and return element at head of queue.
  100  */
  101 queue_entry_t dequeue_head(
  102         register queue_t        que)
  103 {
  104         register queue_entry_t  elt;
  105 
  106         if (que->next == que)
  107                 return((queue_entry_t)0);
  108 
  109         elt = que->next;
  110         elt->next->prev = que;
  111         que->next = elt->next;
  112         return(elt);
  113 }
  114 
  115 /*
  116  *      Remove and return element at tail of queue.
  117  */
  118 queue_entry_t dequeue_tail(
  119         register queue_t        que)
  120 {
  121         register queue_entry_t  elt;
  122 
  123         if (que->prev == que)
  124                 return((queue_entry_t)0);
  125 
  126         elt = que->prev;
  127         elt->prev->next = que;
  128         que->prev = elt->prev;
  129         return(elt);
  130 }
  131 
  132 /*
  133  *      Remove arbitrary element from queue.
  134  *      Does not check whether element is on queue - the world
  135  *      will go haywire if it isn't.
  136  */
  137 
  138 /*ARGSUSED*/
  139 void remqueue(
  140         queue_t                 que,
  141         register queue_entry_t  elt)
  142 {
  143         elt->next->prev = elt->prev;
  144         elt->prev->next = elt->next;
  145 }
  146 
  147 /*
  148  *      Routines to directly imitate the VAX hardware queue
  149  *      package.
  150  */
  151 void insque(
  152         register struct queue_entry *entry,
  153         register struct queue_entry *pred)
  154 {
  155         entry->next = pred->next;
  156         entry->prev = pred;
  157         (pred->next)->prev = entry;
  158         pred->next = entry;
  159 }
  160 
  161 struct queue_entry
  162 *remque(
  163         register struct queue_entry *elt)
  164 {
  165         (elt->next)->prev = elt->prev;
  166         (elt->prev)->next = elt->next;
  167         return(elt);
  168 }
  169 

Cache object: ff9583fd2b779e7ef65415a9b255688a


[ 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.