home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / update701 / root.18 / usr / include / sys / insrem.h / insrem.h
Encoding:
Text File  |  1998-08-18  |  4.4 KB  |  113 lines

  1. /*
  2.  * Copyright (c) 1998 The Santa Cruz Operation, Inc.. All Rights Reserved. 
  3.  *                                                                         
  4.  *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE               
  5.  *                   SANTA CRUZ OPERATION INC.                             
  6.  *                                                                         
  7.  *   The copyright notice above does not evidence any actual or intended   
  8.  *   publication of such source code.                                      
  9.  */
  10.  
  11. /*
  12.  * Copyrighted as an unpublished work.
  13.  * (c) Copyright 1987-1995 Computer Associates International, Inc.
  14.  * All rights reserved.
  15.  *
  16.  * RESTRICTED RIGHTS
  17.  *
  18.  * These programs are supplied under a license.  They may be used,
  19.  * disclosed, and/or copied only as permitted under such license
  20.  * agreement.  Any copy must contain the above copyright notice and
  21.  * this restricted rights notice.  Use, copying, and/or disclosure
  22.  * of the programs is strictly prohibited unless otherwise provided
  23.  * in the license agreement.
  24.  */
  25. /*
  26.  * Copyright (c) 1982-1995
  27.  *      The Regents of the University of California.  All rights reserved.
  28.  *
  29.  * Redistribution and use in source and binary forms, with or without
  30.  * modification, are permitted provided that the following conditions
  31.  * are met:
  32.  * 1. Redistributions of source code must retain the above copyright
  33.  *    notice, this list of conditions and the following disclaimer.
  34.  * 2. Redistributions in binary form must reproduce the above copyright
  35.  *    notice, this list of conditions and the following disclaimer in the
  36.  *    documentation and/or other materials provided with the distribution.
  37.  * 3. All advertising materials mentioning features or use of this software
  38.  *    must display the following acknowledgement:
  39.  *      This product includes software developed by the University of
  40.  *      California, Berkeley and its contributors.
  41.  * 4. Neither the name of the University nor the names of its contributors
  42.  *    may be used to endorse or promote products derived from this software
  43.  *    without specific prior written permission.
  44.  *
  45.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  46.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  47.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  48.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  49.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  50.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  51.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  52.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  53.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  54.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  55.  * SUCH DAMAGE.
  56.  */
  57. #ident "@(#)insrem.h    1.5"
  58. #ident "$Id$"
  59.  
  60. /*
  61.  *
  62.  * A list is headed by a single forward pointer (or an array of forward
  63.  * pointers for a hash table header). The elements are doubly linked
  64.  * so that an arbitrary element can be removed without a need to
  65.  * traverse the list. New elements can be added to the list before
  66.  * or after an existing element or at the head of the list. A list
  67.  * may only be traversed in the forward direction.
  68.  *
  69.  */
  70.  
  71. /*
  72.  * List functions.
  73.  */
  74. #define    LIST_INIT(head)                            \
  75.     (head)->lh_first = NULL;
  76.  
  77. #define LIST_INSERT_HEAD(head, elm, field)                \
  78.     if (((elm)->field.le_next = (head)->lh_first) != NULL)        \
  79.         (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
  80.     (head)->lh_first = (elm);                    \
  81.     (elm)->field.le_prev = &(head)->lh_first;
  82.  
  83. #define LIST_REMOVE(elm, field)                        \
  84.     if ((elm)->field.le_next != NULL)                \
  85.         (elm)->field.le_next->field.le_prev =             \
  86.             (elm)->field.le_prev;                \
  87.     *(elm)->field.le_prev = (elm)->field.le_next;            \
  88.     (elm)->field.le_next = NULL;                    \
  89.     (elm)->field.le_prev = NULL;
  90.  
  91. typedef struct vq {
  92.     void *fwd;
  93.     void *back;
  94. } vq_t;
  95.  
  96. #define DEQUENXT(e)     (e)->fwd = ((vq_t *)(e)->fwd)->fwd
  97.  
  98. #define ENQUE(e, p)     (e)->fwd = (p)->fwd; (p)->fwd = (e)
  99.  
  100. #define INSQUE(e, p)    (e)->back = (p);            \
  101.             (e)->fwd = ((vq_t *)(p)->fwd);        \
  102.             ((vq_t *)(p)->fwd)->back = (e);        \
  103.             (p)->fwd = (e);
  104.  
  105. #define REMQUE(e)    ((vq_t *)(e)->back)->fwd = (e)->fwd;    \
  106.             ((vq_t *)(e)->fwd)->back = (e)->back;    \
  107.             (e)->fwd = NULL;            \
  108.             (e)->back = NULL;
  109.  
  110. /* XXX should go */
  111. #define insque(a, b) INSQUE(a, b)
  112. #define remque(a) REMQUE(a)
  113.