Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. BILINK.H
  5. Abstract:
  6. Management for doubly linked lists
  7. Author:
  8. George Joy
  9. Environment:
  10. 32-bit 'C'
  11. Revision History:
  12. --*/// BILINK.H
  13. // Make sure all variations of DEBUG are defined if any one is
  14. #if defined(DEBUG) || defined(DBG) || defined(_DEBUG)
  15. #if !defined(DBG)
  16. #define DBG
  17. #endif
  18. #if !defined(DEBUG)
  19. #define DEBUG
  20. #endif
  21. #if !defined(_DEBUG)
  22. #define _DEBUG
  23. #endif
  24. #endif
  25. #ifdef __cplusplus
  26. extern "C"
  27. {
  28. #endif // __cplusplus
  29. #ifndef _BILINK_
  30. #define _BILINK_
  31. #if !defined(offsetof)
  32. #define offsetof(type, field) ((int)(&((type *)0)->field))
  33. #endif
  34. #ifndef CONTAINING_RECORD
  35. #define CONTAINING_RECORD(address,type,field) \
  36. ((type *)((PCHAR)(address) - (UINT_PTR)(&((type *)0)->field)))
  37. #endif // CONTAINING_RECORD
  38. typedef struct BILINK {
  39. struct BILINK *next;
  40. struct BILINK *prev;
  41. void *pvObject;
  42. } BILINK;
  43. /* XLATOFF */
  44. #define EMPTY_BILINK(_pBilink) ((_pBilink)->next==(_pBilink))
  45. #ifdef DEBUG
  46. #define ASSERT_EMPTY_BILINK(_b) ASSERT((_b)->next==(_b))
  47. #else
  48. #define ASSERT_EMPTY_BILINK(_b)
  49. #endif
  50. // This only works for BILINKS that are the first item in a structure.
  51. #define BilinkToList( _pBilink ) \
  52. (_pBilink)->prev->next=NULL;
  53. #define InitBilink( _pBilink, _pvObject ) \
  54. (_pBilink)->prev=(_pBilink)->next=(_pBilink); (_pBilink)->pvObject = _pvObject;
  55. #ifdef DEBUG
  56. int FindObject(
  57. BILINK *link,
  58. BILINK *list
  59. );
  60. #endif
  61. void InsertAfter(
  62. BILINK *in,
  63. BILINK *after
  64. );
  65. void InsertBefore(
  66. BILINK *in,
  67. BILINK *before
  68. );
  69. void Delete(
  70. BILINK *p
  71. );
  72. /* XLATON */
  73. #endif
  74. #ifdef __cplusplus
  75. }
  76. #endif // __cplusplus