OpenAFS
OpenAFS distributed network file system
|
00001 /* 00002 * Copyright 2000, International Business Machines Corporation and others. 00003 * All Rights Reserved. 00004 * 00005 * This software has been released under the terms of the IBM Public 00006 * License. For details, see the LICENSE file in the top-level source 00007 * directory or online at http://www.openafs.org/dl/license10.html 00008 */ 00009 00010 /* Copyright (C) 1994 Cazamar Systems, Inc. */ 00011 00012 #ifndef OPENAFS_WINNT_CLIENT_OSI_OSI_QUEUE_H 00013 #define OPENAFS_WINNT_CLIENT_OSI_OSI_QUEUE_H 1 00014 00015 /* this package implements a doubly linked queue of elements. 00016 * Each element starts with an osi_queue_t element. 00017 * 00018 * Utility functions are passed a pointer to a pointer to the first 00019 * element in the list; this word is NULL if the list is empty (the 00020 * pointer to it, of course, is not NULL). 00021 * The list is *not* circularly linked; rather prevp of the first 00022 * element and nextp of the last element are both NULL; this makes 00023 * checking for the end of the list easier, and still provides us a 00024 * quick deletion. 00025 * 00026 * Some of these things are macros for performance reasons. 00027 */ 00028 00029 typedef struct osi_queue { 00030 struct osi_queue *nextp; 00031 struct osi_queue *prevp; 00032 } osi_queue_t; 00033 00034 typedef struct osi_queueData { 00035 osi_queue_t q; 00036 void *datap; 00037 } osi_queueData_t; 00038 00039 /* # of elements to allocate at once */ 00040 #define OSI_NQDALLOC 64 00041 00042 /* add an element to the head of a queue, first parm is 00043 * address of head pointer, and second parm is addr of 00044 * element to add. 00045 */ 00046 extern void osi_QAdd(osi_queue_t **headpp, osi_queue_t *eltp); 00047 00048 /* add an element to the tail of a queue, first parm is 00049 * address of head pointer, second is addr of ptr to tail elt, 00050 * and third parm is addr of element to add. 00051 */ 00052 extern void osi_QAddT(osi_queue_t **headpp, osi_queue_t **tailpp, osi_queue_t *eltp); 00053 00054 /* add to the head (like osi_QAdd) only be prepared to set tailpp if necessary */ 00055 extern void osi_QAddH(osi_queue_t **headpp, osi_queue_t **tailpp, osi_queue_t *eltp); 00056 00057 /* remove an element from a queue; takes address of head list, and 00058 * element to remove as parameters. 00059 */ 00060 extern void osi_QRemove(osi_queue_t **headpp, osi_queue_t *eltp); 00061 00062 /* remove an element from a queue with both head and tail pointers; 00063 * takes address of head and tail lists, and element to remove as parameters. 00064 */ 00065 extern void osi_QRemoveHT(osi_queue_t **headpp, osi_queue_t **tailpp, osi_queue_t *eltp); 00066 00067 /* initialize the queue package */ 00068 extern void osi_InitQueue(void); 00069 00070 /* allocate a queue element with one data ptr */ 00071 extern osi_queueData_t *osi_QDAlloc(void); 00072 00073 /* free a single element queue pointer */ 00074 extern void osi_QDFree(osi_queueData_t *); 00075 00076 /* retrieve the queue data from a one-element block */ 00077 #define osi_GetQData(x) ((x)->datap) 00078 00079 /* set the queue data in a one-element block */ 00080 #define osi_SetQData(x,y) ((x)->datap = (y)) 00081 00082 /* get the next ptr from a queue element */ 00083 #define osi_QNext(x) ((x)->nextp) 00084 00085 /* get the prev ptr from a queue element */ 00086 #define osi_QPrev(x) ((x)->prevp) 00087 00088 /* find out if a queue is empty */ 00089 #define osi_QIsEmpty(x) ((*x) == ((osi_queue_t *) 0)) 00090 00091 #endif /* OPENAFS_WINNT_CLIENT_OSI_OSI_QUEUE_H */