1 /*
2  * (c) Copyright 1990-1996 OPEN SOFTWARE FOUNDATION, INC.
3  * (c) Copyright 1990-1996 HEWLETT-PACKARD COMPANY
4  * (c) Copyright 1990-1996 DIGITAL EQUIPMENT CORPORATION
5  * (c) Copyright 1991, 1992 Siemens-Nixdorf Information Systems
6  * To anyone who acknowledges that this file is provided "AS IS" without
7  * any express or implied warranty: permission to use, copy, modify, and
8  * distribute this file for any purpose is hereby granted without fee,
9  * provided that the above copyright notices and this notice appears in
10  * all source code copies, and that none of the names listed above be used
11  * in advertising or publicity pertaining to distribution of the software
12  * without specific, written prior permission.  None of these organizations
13  * makes any representations about the suitability of this software for
14  * any purpose.
15  */
16 /*
17  *	Header file for generic list functions operating on singly linked
18  *	null-terminated lists.  Items may not be REMOVED from the list!  The
19  *	intent is that the list can be traversed (for read-only operations)
20  *	without locking, since insertion is "safe" (though not truely
21  *	atomic).  THIS ASSUMES THAT THE HARDWARE MAKES WRITES VISIBLE TO READS
22  *	IN THE ORDER IN WHICH THEY OCCURRED!  WITHOUT SUCH READ/WRITE
23  *	ORDERING, IT MAY BE NECESSARY TO INSERT "BARRIERS" TO PRODUCE THE
24  *	REQUIRED VISIBILITY!
25  */
26 
27 #ifndef CMA_LIST
28 #define CMA_LIST
29 
30 /*
31  *  INCLUDE FILES
32  */
33 
34 #include <cma.h>
35 
36 /*
37  * CONSTANTS AND MACROS
38  */
39 
40 #define cma__c_null_list	((cma__t_list *)cma_c_null_ptr)
41 
42 /*
43  * Test whether a list is empty.  Return cma_c_true if so, else
44  * cma_c_false.
45  */
46 #define cma__list_empty(head)	((head)->link == cma__c_null_list)
47 
48 /*
49  * Initialize a queue header to empty.
50  */
51 #define cma__list_init(head)	(void)((head)->link = cma__c_null_list)
52 
53 /*
54  * Insert an element in a list following the specified item (or at the
55  * beginning of the list if "list" is the list head).  NOTE: insertion
56  * operations should be interlocked by the caller!
57  */
58 #define cma__list_insert(element,list)    (void)(	\
59     (element)->link		= (list)->link,		\
60     (list)->link		= (element))
61 
62 /*
63  * Return the next item in a list (or the first, if the address is of the
64  * list header)
65  */
66 #define cma__list_next(element)    ((element)->link)
67 
68 /*
69  * TYPEDEFS
70  */
71 
72 typedef struct CMA__T_LIST {
73     struct CMA__T_LIST	*link;		/* Forward link */
74     } cma__t_list;
75 
76 /*
77  *  GLOBAL DATA
78  */
79 
80 /*
81  * INTERNAL INTERFACES
82  */
83 
84 #endif
85