PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/jsclist.h

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
C++ Header | 139 lines | 51 code | 15 blank | 73 comment | 1 complexity | 8a17b2e8ddc4693f3cbec0493b59cd13 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is Mozilla Communicator client code, released
  16. * March 31, 1998.
  17. *
  18. * The Initial Developer of the Original Code is
  19. * Netscape Communications Corporation.
  20. * Portions created by the Initial Developer are Copyright (C) 1998
  21. * the Initial Developer. All Rights Reserved.
  22. *
  23. * Contributor(s):
  24. *
  25. * Alternatively, the contents of this file may be used under the terms of
  26. * either of the GNU General Public License Version 2 or later (the "GPL"),
  27. * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. * in which case the provisions of the GPL or the LGPL are applicable instead
  29. * of those above. If you wish to allow use of your version of this file only
  30. * under the terms of either the GPL or the LGPL, and not to allow others to
  31. * use your version of this file under the terms of the MPL, indicate your
  32. * decision by deleting the provisions above and replace them with the notice
  33. * and other provisions required by the GPL or the LGPL. If you do not delete
  34. * the provisions above, a recipient may use your version of this file under
  35. * the terms of any one of the MPL, the GPL or the LGPL.
  36. *
  37. * ***** END LICENSE BLOCK ***** */
  38. #ifndef jsclist_h___
  39. #define jsclist_h___
  40. #include "jstypes.h"
  41. /*
  42. ** Circular linked list
  43. */
  44. typedef struct JSCListStr {
  45. struct JSCListStr *next;
  46. struct JSCListStr *prev;
  47. } JSCList;
  48. /*
  49. ** Insert element "_e" into the list, before "_l".
  50. */
  51. #define JS_INSERT_BEFORE(_e,_l) \
  52. JS_BEGIN_MACRO \
  53. (_e)->next = (_l); \
  54. (_e)->prev = (_l)->prev; \
  55. (_l)->prev->next = (_e); \
  56. (_l)->prev = (_e); \
  57. JS_END_MACRO
  58. /*
  59. ** Insert element "_e" into the list, after "_l".
  60. */
  61. #define JS_INSERT_AFTER(_e,_l) \
  62. JS_BEGIN_MACRO \
  63. (_e)->next = (_l)->next; \
  64. (_e)->prev = (_l); \
  65. (_l)->next->prev = (_e); \
  66. (_l)->next = (_e); \
  67. JS_END_MACRO
  68. /*
  69. ** Return the element following element "_e"
  70. */
  71. #define JS_NEXT_LINK(_e) \
  72. ((_e)->next)
  73. /*
  74. ** Return the element preceding element "_e"
  75. */
  76. #define JS_PREV_LINK(_e) \
  77. ((_e)->prev)
  78. /*
  79. ** Append an element "_e" to the end of the list "_l"
  80. */
  81. #define JS_APPEND_LINK(_e,_l) JS_INSERT_BEFORE(_e,_l)
  82. /*
  83. ** Insert an element "_e" at the head of the list "_l"
  84. */
  85. #define JS_INSERT_LINK(_e,_l) JS_INSERT_AFTER(_e,_l)
  86. /* Return the head/tail of the list */
  87. #define JS_LIST_HEAD(_l) (_l)->next
  88. #define JS_LIST_TAIL(_l) (_l)->prev
  89. /*
  90. ** Remove the element "_e" from it's circular list.
  91. */
  92. #define JS_REMOVE_LINK(_e) \
  93. JS_BEGIN_MACRO \
  94. (_e)->prev->next = (_e)->next; \
  95. (_e)->next->prev = (_e)->prev; \
  96. JS_END_MACRO
  97. /*
  98. ** Remove the element "_e" from it's circular list. Also initializes the
  99. ** linkage.
  100. */
  101. #define JS_REMOVE_AND_INIT_LINK(_e) \
  102. JS_BEGIN_MACRO \
  103. (_e)->prev->next = (_e)->next; \
  104. (_e)->next->prev = (_e)->prev; \
  105. (_e)->next = (_e); \
  106. (_e)->prev = (_e); \
  107. JS_END_MACRO
  108. /*
  109. ** Return non-zero if the given circular list "_l" is empty, zero if the
  110. ** circular list is not empty
  111. */
  112. #define JS_CLIST_IS_EMPTY(_l) \
  113. ((_l)->next == (_l))
  114. /*
  115. ** Initialize a circular list
  116. */
  117. #define JS_INIT_CLIST(_l) \
  118. JS_BEGIN_MACRO \
  119. (_l)->next = (_l); \
  120. (_l)->prev = (_l); \
  121. JS_END_MACRO
  122. #define JS_INIT_STATIC_CLIST(_l) \
  123. {(_l), (_l)}
  124. #endif /* jsclist_h___ */