Files @ d6b9b2ac5869
Branch filter:

Location: vmkdrivers/BLD/build/HEADERS/vmkapi-current-all-public-bincomp/vmkernel64/release/lib/vmkapi_list.h

unknown
ESXi-5.5-U2
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
/* **********************************************************
 * Copyright 2006 - 2010 VMware, Inc.  All rights reserved.
 * **********************************************************/

/* **********************************************************
 * Portions of the code in this file require the following
 * copyright notice to be displayed:
 *
 * Copyright (C) 1985, 1988 Regents of the University of California
 * Permission to use, copy, modify, and distribute this
 * software and its documentation for any purpose and without
 * fee is hereby granted, provided that the above copyright
 * notice appear in all copies.  The University of California
 * makes no representations about the suitability of this
 * software for any purpose.  It is provided "as is" without
 * express or implied warranty.
 * **********************************************************/

/*
 * @VMKAPIMOD_LICENSE@
 */

/*
 ***********************************************************************
 * List                                                           */ /**
 * \addtogroup Lib
 * @{
 * \defgroup List Doubly-Linked Lists
 *
 * The following are interfaces for a list abstraction  which enables
 * arbitrary data structures to be linked together into a doubly-linked
 * circular list.
 *
 * A list is composed of a sentinel header and its real members, if any.
 * Thus, an empty list consists of a single header element whose nextPtr
 * and prevPtr fields point to itself.
 *
 * The links are contained in a two-element structure called vmk_ListLinks.
 * A list joins vmk_ListLinks records (that is, each vmk_ListLinks structure
 * points to other vmk_ListLinks structures), but if the vmk_ListLinks is the
 * first field within a larger structure, then the larger structures are
 * effectively linked together as follows:
 *
 * \code
 *            header
 *        (vmk_ListLinks)          First element           Second Element
 *      -----------------       ------------------       -----------------
 * ..-> |    nextPtr    | ----> |  vmk_ListLinks | ----> | vmk_ListLinks |  ----..
 *      | - - - - - - - |       |                |       |               |
 * ..-- |    prevPtr    | <---- |                | <---- |               | <---..
 *      -----------------       - ---  ---  --- -        - ---  ---  --- -
 *                              |    rest of     |       |    rest of    |
 *                              |   structure    |       |   structure   |
 *                              |                |       |               |
 *                              |      ...       |       |      ...      |
 *                              -----------------        -----------------
 * \endcode
 *
 * It is possible to link structures through vmk_ListLinks fields that are
 * not at the beginning of the larger structure, but it is then necessary
 * to use VMK_LIST_ENTRY to extract the surrounding structure from
 * the list element.
 *
 * \par A typical structure might be something like:
 *
 * \code
 * typedef struct {
 *    vmk_ListLinks links;
 *    char ch;
 *    integer flags;
 * } Example;
 * \endcode
 *
 * @{
 ***********************************************************************
 */

#ifndef _VMKAPI_LIST_H_
#define _VMKAPI_LIST_H_

/** \cond never */
#ifndef VMK_HEADER_INCLUDED_FROM_VMKAPI_H
#error This vmkapi file should never be included directly but only via vmkapi.h
#endif
/** \endcond never */

/**
 * \brief List links container.
 */
typedef struct vmk_ListLinks {
   struct vmk_ListLinks *prevPtr;
   struct vmk_ListLinks *nextPtr;
} vmk_ListLinks;


/*
 ***********************************************************************
 * VMK_LIST_ENTRY --                                              */ /**
 *
 * \brief Get a pointer to the structure containing a given list
 *        element.
 *
 * \param[in] itemPtr            List element that is contained by
 *                               another structure.
 * \param[in] containerType      C type of the container.
 * \param[in] fieldInContainer   Name of the structure field in the
 *                               container that itemPtr is pointing to.
 *
 * This macro allows a list pointer embedded in a structure to be
 * somwhere other than the initial item in the structure.
 *
 * \par Example:
 * \code
 * typedef struct
 * {
 *     int a;
 *     vmk_ListLinks links;
 *     int b;
 * }
 * myType;
 *
 * myType example;
 * myType *ptr;
 * vmk_ListLinks *listElem;
 *
 * listElem = &(example.links);
 * ptr = VMK_LIST_ENTRY(listElem, myType, links);
 * \endcode
 * "ptr" should now point at "example"
 *
 ***********************************************************************
 */
#define VMK_LIST_ENTRY(itemPtr, containerType, fieldInContainer) \
  ((containerType *) ((vmk_uint8 *) (itemPtr) - \
                      ((unsigned long) &((containerType *)0)->fieldInContainer)))

/*
 ***********************************************************************
 * vmk_ListInit --                                                */ /**
 *
 * \brief Initialize a header pointer to point to an empty list.
 *
 * \param[in] headerPtr    List header to initialize.
 *
 ***********************************************************************
 */
static inline void
vmk_ListInit(vmk_ListLinks *headerPtr)
{
   VMK_ASSERT(headerPtr != NULL);
   headerPtr->nextPtr = headerPtr;
   headerPtr->prevPtr = headerPtr;
}

/*
 ***********************************************************************
 * vmk_ListInitElement --                                         */ /**
 *
 * \brief Initialize a list element.
 *
 * \param[in] elementPtr   List element to initialize.
 *
 ***********************************************************************
 */
static inline void
vmk_ListInitElement(vmk_ListLinks *elementPtr)
{
    elementPtr->prevPtr = (vmk_ListLinks *) NULL;
    elementPtr->nextPtr = (vmk_ListLinks *) NULL;
}


/*
 ***********************************************************************
 * vmk_ListIsUnlinkedElement --                                   */ /**
 *
 * \brief Check whether a given element is part of a list or not.
 *
 * \param[in] elementPtr   List element to check.
 *
 * \retval VMK_TRUE     The element is not in a list.
 * \retval VMK_FALSE    The element is linked into a list.
 *
 ***********************************************************************
 */
static inline vmk_Bool
vmk_ListIsUnlinkedElement(vmk_ListLinks *elementPtr)
{
   return (elementPtr->prevPtr == (vmk_ListLinks *) NULL &&
           elementPtr->nextPtr == (vmk_ListLinks *) NULL);
}


/*
 ***********************************************************************
 * VMK_LIST_FORALL --                                             */ /**
 *
 * \brief for-loop replacement macro to scan through a list from
 *        the first to the last list member.
 *
 * \param[in]  headerPtr   The list to scan
 * \param[out] itemPtr     Loop pointer that is updated with the current
 *                         list member each time through the loop.
 *
 * \note This macro does not tolerate the removal of itemPtr from
 *      the list during the loop.
 *
 * \sa VMK_LIST_FORALL_SAFE
 *
 ***********************************************************************
 */
#define VMK_LIST_FORALL(headerPtr, itemPtr) \
        for (itemPtr = vmk_ListFirst(headerPtr); \
             !vmk_ListIsAtEnd((headerPtr),itemPtr); \
             itemPtr = vmk_ListNext(itemPtr))


/*
 ***********************************************************************
 * VMK_LIST_FORALL_REVERSE --                                     */ /**
 *
 * \brief for-loop replacement macro to scan through a list from
 *        the last to the first list member.
 *
 * \param[in]  headerPtr   The list to scan
 * \param[out] itemPtr     Loop pointer that is updated with the current
 *                         list member each time through the loop.
 *
 * \note This macro does not tolerate the removal of itemPtr from
 *       the list during the loop.
 *
 * \sa VMK_LIST_FORALL_REVERSE_SAFE
 *
 ***********************************************************************
 */
#define VMK_LIST_FORALL_REVERSE(headerPtr, itemPtr) \
        for (itemPtr = vmk_ListLast(headerPtr); \
             !vmk_ListIsAtEnd((headerPtr),itemPtr); \
             itemPtr = vmk_ListPrev(itemPtr))


/*
 ***********************************************************************
 * VMK_LIST_FORALL_SAFE --                                        */ /**
 *
 * \brief for-loop replacement macro to scan through a list from
 *        the first to the last list member.
 *
 * \param[in]  headerPtr   The list to scan.
 * \param[out] itemPtr     Loop pointer that is updated each time
 *                         through the loop with the current list member.
 * \param[out] nextPtr     Loop pointer that is updated each time
 *                         through the loop with the next list member.
 *
 * \note This macro should be used if itemPtr must be removed from
 *       the list during the loop.
 *
 ***********************************************************************
 */
#define VMK_LIST_FORALL_SAFE(headerPtr, itemPtr, nextPtr) \
        for (itemPtr = vmk_ListFirst(headerPtr), nextPtr = vmk_ListNext(itemPtr); \
             !vmk_ListIsAtEnd((headerPtr),itemPtr); \
             itemPtr = nextPtr, nextPtr = vmk_ListNext(nextPtr))


/*
 ***********************************************************************
 * VMK_LIST_FORALL_REVERSE_SAFE --                                */ /**
 *
 * \brief for-loop replacement macro to scan through a list from
 *        the last to the first list member.
 *
 * \param[in]  headerPtr   The list to scan.
 * \param[out] itemPtr     Loop pointer that is updated each time
 *                         through the loop with the current list member.
 * \param[out] prevPtr     Loop pointer that is updated each time
 *                         through the loop with the next list member.
 *
 * \note This macro should be used if itemPtr must be removed from
 *       the list during the loop.
 *
 ***********************************************************************
 */
#define VMK_LIST_FORALL_REVERSE_SAFE(headerPtr, itemPtr, prevPtr) \
        for (itemPtr = vmk_ListLast(headerPtr), prevPtr = vmk_ListPrev(itemPtr); \
             !vmk_ListIsAtEnd((headerPtr),itemPtr); \
             itemPtr = prevPtr, prevPtr = vmk_ListPrev(prevPtr))


/*
 ***********************************************************************
 * VMK_LIST_ITER --                                               */ /**
 *
 * \brief while-loop replacement macro to scan through a list from
 *        a given list member to the last list member.
 *
 * \param[in]     headerPtr   The list to scan.
 * \param[in,out] itemPtr     The first list member to scan. This pointer
 *                            is also updated with the current list member
 *                            each time through the loop.
 *
 * \note This macro does not tolerate the removal of itemPtr from the
 *       list during the loop.
 *
 * \sa VMK_LIST_ITER_SAFE
 *
 ***********************************************************************
 */
#define VMK_LIST_ITER(headerPtr, itemPtr) \
        for (; \
             !vmk_ListIsAtEnd((headerPtr),itemPtr); \
             itemPtr = vmk_ListNext(itemPtr))


/*
 ***********************************************************************
 * VMK_LIST_ITER_REVERSE --                                       */ /**
 *
 * \brief while-loop replacement macro to scan through a list from
 *        a given list member to the first list member.
 *
 * \param[in]     headerPtr   The list to scan.
 * \param[in,out] itemPtr     The first list member to scan. This pointer
 *                            is also updated with the current list member
 *                            each time through the loop.
 *
 * \note This macro does not tolerate the removal of itemPtr from the
 *       list during the loop.
 *
 * \sa VMK_LIST_ITER_REVERSE_SAFE
 *
 ***********************************************************************
 */
#define VMK_LIST_ITER_REVERSE(headerPtr, itemPtr) \
        for (; \
             !vmk_ListIsAtEnd((headerPtr),itemPtr); \
             itemPtr = vmk_ListPrev(itemPtr))


/*
 ***********************************************************************
 * VMK_LIST_ITER_SAFE --                                          */ /**
 *
 * \brief while-loop replacement macro to scan through a list from
 *        a given list member to the last list member.
 *
 * \param[in] headerPtr    The list to scan.
 * \param[in,out] itemPtr  The first list member to scan. This pointer
 *                         is also updated with the current list member
 *                         each time through the loop.
 * \param[out] nextPtr     Loop pointer that is updated each time through
 *                         the loop with the next list member.
 *
 * \note This macro should be used if itemPtr must be removed from
 *       the list during the loop.
 *
 ***********************************************************************
 */
#define VMK_LIST_ITER_SAFE(headerPtr, itemPtr, nextPtr) \
        for (nextPtr = vmk_ListNext(itemPtr); \
             !vmk_ListIsAtEnd((headerPtr),itemPtr); \
             itemPtr = nextPtr, nextPtr = vmk_ListNext(nextPtr))


/*
 ***********************************************************************
 * VMK_LIST_ITER_REVERSE_SAFE --                                  */ /**
 *
 * \brief while-loop replacement macro to scan through a list from
 *        a given list member to the first list member.
 *
 * \param[in] headerPtr    The list to scan.
 * \param[in,out] itemPtr  The first list member to scan. This pointer
 *                         is also updated with the current list member
 *                         each time through the loop.
 * \param[out] prevPtr     Loop pointer that is updated each time through
 *                         the loop with the next list member.
 *
 * \note This macro should be used if itemPtr must be removed from
 *       the list during the loop.
 *
 ***********************************************************************
 */
#define VMK_LIST_ITER_REVERSE_SAFE(headerPtr, itemPtr, prevPtr) \
        for (prevPtr = vmk_ListPrev(itemPtr); \
             !vmk_ListIsAtEnd((headerPtr),itemPtr); \
             itemPtr = prevPtr, prevPtr = vmk_ListPrev(prevPtr))


/*
 ***********************************************************************
 * vmk_ListIsEmpty --                                             */ /**
 *
 * \brief Check if a list does not contain any members.
 *
 * \param[in] headerPtr    The head of the list to check
 *
 * \retval VMK_TRUE     The list is empty
 * \retval VMK_FALSE    The list is not empty
 *
 ***********************************************************************
 */
static inline vmk_Bool
vmk_ListIsEmpty(vmk_ListLinks *headerPtr)
{
   return (headerPtr == headerPtr->nextPtr);
}


/*
 ***********************************************************************
 * vmk_ListIsAtEnd --                                             */ /**
 *
 * \brief Check if itemPtr is pointing just past the last list element.
 *
 * This function is useful for loops where it can be used to check if
 * the loop has scanned all the list elements by checking to see if
 * the loop's list pointer has scanned past the end of the list.
 *
 * \param[in] headerPtr  The head of the list to check.
 * \param[in] itemPtr    The list entry pointer to check.
 *
 * \retval VMK_TRUE     itemPtr points past the last list element.
 * \retval VMK_FALSE    itemPtr does not point past the last
 *                      list element.
 *
 ***********************************************************************
 */
static inline vmk_Bool
vmk_ListIsAtEnd(vmk_ListLinks *headerPtr, vmk_ListLinks *itemPtr)
{
   return (itemPtr == headerPtr);
}


/*
 ***********************************************************************
 * vmk_ListFirst --                                               */ /**
 *
 * \brief Get the first list member in a list.
 *
 * \param[in] headerPtr    The list from which to retrieve the element.
 *
 * \return A pointer to the first member in the list.
 *
 ***********************************************************************
 */
static inline vmk_ListLinks *
vmk_ListFirst(vmk_ListLinks *headerPtr)
{
   return (headerPtr->nextPtr);
}


/*
 ***********************************************************************
 * vmk_ListLast --                                                */ /**
 *
 * \brief Get the last list member in a list.
 *
 * \param[in] headerPtr    The list from which to retrieve the element.
 *
 * \return A pointer to the last member in the list
 *
 ***********************************************************************
 */
static inline vmk_ListLinks *
vmk_ListLast(vmk_ListLinks *headerPtr)
{
   return (headerPtr->prevPtr);
}


/*
 ***********************************************************************
 * vmk_ListPrev --                                                */ /**
 *
 * \brief Return the preceeding list memeber.
 *
 * This function will return the list header if the memeber is the
 * first list member.
 *
 * \param[in] itemPtr   The list member from which to get the
 *                      previous member.
 *
 * \return A pointer to the preceeding list member
 *
 ***********************************************************************
 */
static inline vmk_ListLinks *
vmk_ListPrev(vmk_ListLinks *itemPtr)
{
   return (itemPtr->prevPtr);
}


/*
 ***********************************************************************
 * vmk_ListNext --                                                */ /**
 *
 * \brief Return the following list memeber .
 *
 * This function will return the list header if the memeber is the
 * last list member.
 *
 * \param[in] itemPtr   The list member from which to get the
 *                      following member.
 *
 * \return A pointer to the following list member.
 *
 ***********************************************************************
 */
static inline vmk_ListLinks *
vmk_ListNext(vmk_ListLinks *itemPtr)
{
   return (itemPtr->nextPtr);
}


/*
 ***********************************************************************
 * vmk_ListInsert --                                              */ /**
 *
 * \brief Insert a list element into a list after another element.
 *
 * vmk_ListAfter, vmk_ListBefore, vmk_ListAtFront, and
 * vmk_ListAtRear can be used to determine destPtr.
 *
 * \par For example:
 * \code
 * vmk_ListInsert(myElement, vmk_ListAtFront(myList));
 * \endcode
 *
 * \param[in] itemPtr   List element to insert in the list.
 * \param[in] destPtr   List member to insert after.
 *
 ***********************************************************************
 */
static inline void
vmk_ListInsert(vmk_ListLinks *itemPtr, vmk_ListLinks *destPtr)
{
   VMK_ASSERT(itemPtr != NULL && destPtr != NULL);
   VMK_ASSERT(itemPtr != destPtr);  /* Can't insert something after itself. */
   itemPtr->nextPtr = destPtr->nextPtr;
   itemPtr->prevPtr = destPtr;
   destPtr->nextPtr->prevPtr = itemPtr;
   destPtr->nextPtr = itemPtr;
}


/*
 ***********************************************************************
 * vmk_ListAfter --                                                */ /**
 *
 * \brief Get the appropriate itemPtr for vmk_ListInsert
 *        so that insertion will take place after a given element.
 *
 * \param[in] itemPtr   List member to insert after.
 *
 * \return A pointer to a list element that will allow list
 *         insertion after the given list member.
 *
 ***********************************************************************
 */
static inline vmk_ListLinks *
vmk_ListAfter(vmk_ListLinks *itemPtr)
{
   return itemPtr;
}


/*
 ***********************************************************************
 * vmk_ListBefore --                                              */ /**
 *
 * \brief Get the appropriate itemPtr for vmk_ListInsert()
 *        so that insertion will take place before a given element.
 *
 * \param[in] itemPtr   List member to insert before.
 *
 * \return A pointer to a list element that will allow list
 *         insertion before the given list member.
 *
 ***********************************************************************
 */
static inline vmk_ListLinks *
vmk_ListBefore(vmk_ListLinks *itemPtr)
{
   return itemPtr->prevPtr;
}


/*
 ***********************************************************************
 * vmk_ListAtFront --                                             */ /**
 *
 * \brief Get the appropriate itemPtr for vmk_ListInsert() to insert
 *        at the head of a given list.
 *
 * \param[in] headerPtr    List on which the insertion will take place.
 *
 * \return A pointer to a list element that will allow list insertion
 *         at the head of the given list.
 *
 ***********************************************************************
 */
static inline vmk_ListLinks *
vmk_ListAtFront(vmk_ListLinks *headerPtr)
{
   return headerPtr;
}


/*
 ***********************************************************************
 * vmk_ListAtRear --                                              */ /**
 *
 * \brief Get the appropriate itemPtr for vmk_ListInsert() to insert
 *        at the tail of a given list.
 *
 * \param[in] headerPtr    List on which the insertion will take place.
 *
 * \return A pointer to the list element that will allow list insertion
 *         at the tail of the given list.
 *
 ***********************************************************************
 */
static inline vmk_ListLinks *
vmk_ListAtRear(vmk_ListLinks *headerPtr)
{
   return headerPtr->prevPtr;
}


/*
 ***********************************************************************
 * vmk_ListRemove --                                              */ /**
 *
 * \brief Remove a list element from the list in which it is contained.
 *
 * \param[in] itemPtr   List element to be removed.
 *
 ***********************************************************************
 */
static inline void
vmk_ListRemove(vmk_ListLinks *itemPtr)
{
   VMK_ASSERT(itemPtr != NULL && itemPtr != itemPtr->nextPtr);
   VMK_ASSERT(itemPtr->prevPtr->nextPtr == itemPtr &&
              itemPtr->nextPtr->prevPtr == itemPtr);
   itemPtr->prevPtr->nextPtr = itemPtr->nextPtr;
   itemPtr->nextPtr->prevPtr = itemPtr->prevPtr;
   vmk_ListInitElement(itemPtr);
}


/*
 ***********************************************************************
 * vmk_ListSplitBefore --                                         */ /**
 *
 * \brief Remove items from the head of a list up to and including
 *        a given list member and put them at the head of another list.
 *
 * \param[in] headerPtr    The source list from which the members will
 *                         be moved.
 * \param[in] headerPtr2   The destination list to which the members
 *                         will be moved.
 * \param[in] itemPtr      The list member in the source list that is
 *                         the last element to be moved.
 *
 ***********************************************************************
 */
static inline void
vmk_ListSplitBefore(vmk_ListLinks *headerPtr, vmk_ListLinks *headerPtr2,
                    vmk_ListLinks *itemPtr)
{
   VMK_ASSERT(headerPtr);
   VMK_ASSERT(headerPtr2);
   VMK_ASSERT(headerPtr != headerPtr2);
   VMK_ASSERT(vmk_ListIsEmpty(headerPtr2));

   /* set up new list */
   headerPtr2->nextPtr = headerPtr->nextPtr;
   headerPtr2->prevPtr = itemPtr;

   /* fix old list */
   headerPtr->nextPtr = itemPtr->nextPtr;
   itemPtr->nextPtr->prevPtr = headerPtr;

   /* fix rest of new list entries */
   itemPtr->nextPtr = headerPtr2;
   headerPtr2->nextPtr->prevPtr = headerPtr2;
}


/*
 ***********************************************************************
 * vmk_ListSplitAfter --                                           */ /**
 *
 * \brief Remove items from the tail of a list up to and including
 *        a given list member and puts them at the tail of another list.
 *
 * \param[in] headerPtr       The non-empty source list from which the
 *                            members will be moved.
 * \param[in] headerPtr2      The empty destination list to which the
 *                            members will be moved.
 * \param[in] itemPtr         The list member in the source list that is
 *                            the first element to be moved.
 *
 ***********************************************************************
 */
static inline void
vmk_ListSplitAfter(vmk_ListLinks *headerPtr, vmk_ListLinks *headerPtr2,
                   vmk_ListLinks *itemPtr)
{
   VMK_ASSERT(headerPtr);
   VMK_ASSERT(headerPtr2);
   VMK_ASSERT(headerPtr != headerPtr2);
   VMK_ASSERT(!vmk_ListIsEmpty(headerPtr));
   VMK_ASSERT(vmk_ListIsEmpty(headerPtr2));

   /* set up new list */
   headerPtr2->prevPtr = headerPtr->prevPtr;
   headerPtr2->nextPtr = itemPtr;

   /* fix old list */
   headerPtr->prevPtr = itemPtr->prevPtr;
   itemPtr->prevPtr->nextPtr = headerPtr;

   /* fix rest of new list entries */
   itemPtr->prevPtr = headerPtr2;
   headerPtr2->prevPtr->nextPtr = headerPtr2;
}

#endif /* _VMKAPI_LIST_H_ */
/** @} */
/** @} */