home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / list.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  2.0 KB  |  71 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _SYS_LIST_H
  11. #define _SYS_LIST_H
  12.  
  13. #ident    "@(#)/usr/include/sys/list.h.sl 1.1 4.0 12/08/90 55703 AT&T-USL"
  14. /* Generic lists
  15.  * Lists are circular and doubly-linked, with headers.
  16.  * When a list is empty, both pointers in the header
  17.  * point to the header itself.
  18.  */
  19.  
  20. /* list element */
  21. typedef struct ls_elt {
  22.     struct ls_elt *ls_next;
  23.     struct ls_elt *ls_prev;
  24.     /* your ad in this space */
  25. } ls_elt_t;
  26.  
  27. /* 
  28.  * All take as arguments side effect-free pointers to list structures
  29.  */
  30. #define LS_ISEMPTY(listp)    \
  31.     (((struct ls_elt *)(listp))->ls_next == (struct ls_elt *)(listp))
  32. #define LS_INIT(listp) {            \
  33.     ((struct ls_elt *)(listp))->ls_next =    \
  34.     ((struct ls_elt *)(listp))->ls_prev =    \
  35.     ((struct ls_elt *)(listp));        \
  36. }
  37.  
  38. #define LS_REMOVE(listp)    ls_remove((struct ls_elt *)(listp))
  39.  
  40. /* 
  41.  * For these five, ptrs are to list elements, but qp and stackp are
  42.  * implicitly headers.
  43.  */
  44. #define LS_INS_BEFORE(oldp, newp)    \
  45.     ls_ins_before((struct ls_elt *)(oldp), (struct ls_elt *)(newp))
  46.  
  47. #define LS_INS_AFTER(oldp, newp)    \
  48.     ls_ins_after((struct ls_elt *)(oldp), (struct ls_elt *)(newp))
  49.  
  50. #define LS_INSQUE(qp, eltp)    \
  51.     ls_ins_before((struct ls_elt *)(qp), (struct ls_elt *)(eltp))
  52.  
  53. /* result needs cast; NULL result if empty queue
  54.  */
  55. #define LS_REMQUE(qp)        ls_remque((struct ls_elt *)(qp))
  56.  
  57. #define LS_PUSH(stackp, newp) \
  58.     ls_ins_after((struct ls_elt *)(stackp), (struct ls_elt *)(newp))
  59.  
  60. /* result needs cast; NULL result if empty stack
  61.  */
  62. #define LS_POP(stackp)        ls_remque((struct ls_elt *)(stackp))
  63.  
  64. extern void ls_ins_before();
  65. extern void ls_ins_after();
  66. extern struct ls_elt *ls_remque();
  67. extern void ls_remove();
  68.  
  69.  
  70. #endif    /* _SYS_LIST_H */
  71.