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.

144 lines
4.6 KiB

  1. /**
  2. @file
  3. @ingroup mtr
  4. @brief Internal data structures of the mtr package
  5. @author Fabio Somenzi
  6. @copyright@parblock
  7. Copyright (c) 1995-2015, Regents of the University of Colorado
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions
  11. are met:
  12. Redistributions of source code must retain the above copyright
  13. notice, this list of conditions and the following disclaimer.
  14. Redistributions in binary form must reproduce the above copyright
  15. notice, this list of conditions and the following disclaimer in the
  16. documentation and/or other materials provided with the distribution.
  17. Neither the name of the University of Colorado nor the names of its
  18. contributors may be used to endorse or promote products derived from
  19. this software without specific prior written permission.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  23. FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  24. COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  26. BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  30. ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  31. POSSIBILITY OF SUCH DAMAGE.
  32. @endparblock
  33. */
  34. #ifndef MTRINT_H_
  35. #define MTRINT_H_
  36. /*---------------------------------------------------------------------------*/
  37. /* Nested includes */
  38. /*---------------------------------------------------------------------------*/
  39. #include "config.h"
  40. #include "mtr.h"
  41. /*---------------------------------------------------------------------------*/
  42. /* Constant declarations */
  43. /*---------------------------------------------------------------------------*/
  44. #ifndef SIZEOF_VOID_P
  45. #define SIZEOF_VOID_P 4
  46. #endif
  47. #ifndef SIZEOF_INT
  48. #define SIZEOF_INT 4
  49. #endif
  50. #if defined(__GNUC__)
  51. #define MTR_INLINE __inline__
  52. # if (__GNUC__ >2 || __GNUC_MINOR__ >=7)
  53. # define MTR_UNUSED __attribute__ ((unused))
  54. # else
  55. # define MTR_UNUSED
  56. # endif
  57. #else
  58. #define MTR_INLINE
  59. #define MTR_UNUSED
  60. #endif
  61. /* MTR_MAXHIGH is defined in such a way that on 32-bit and 64-bit
  62. ** machines one can cast a value to (int) without generating a negative
  63. ** number.
  64. */
  65. #if SIZEOF_VOID_P == 8
  66. #define MTR_MAXHIGH (((MtrHalfWord) ~0) >> 1)
  67. #else
  68. #define MTR_MAXHIGH ((MtrHalfWord) ~0)
  69. #endif
  70. /*---------------------------------------------------------------------------*/
  71. /* Type declarations */
  72. /*---------------------------------------------------------------------------*/
  73. /**
  74. * @brief unsigned integer half the size of a pointer.
  75. */
  76. #if SIZEOF_VOID_P == 8
  77. typedef uint32_t MtrHalfWord;
  78. #else
  79. typedef uint16_t MtrHalfWord;
  80. #endif
  81. /*---------------------------------------------------------------------------*/
  82. /* Stucture declarations */
  83. /*---------------------------------------------------------------------------*/
  84. /**
  85. * @brief multi-way tree node.
  86. */
  87. struct MtrNode_ {
  88. MtrHalfWord flags;
  89. MtrHalfWord low;
  90. MtrHalfWord size;
  91. MtrHalfWord index;
  92. struct MtrNode_ *parent;
  93. struct MtrNode_ *child;
  94. struct MtrNode_ *elder;
  95. struct MtrNode_ *younger;
  96. };
  97. /*---------------------------------------------------------------------------*/
  98. /* Variable declarations */
  99. /*---------------------------------------------------------------------------*/
  100. /*---------------------------------------------------------------------------*/
  101. /* Macro declarations */
  102. /*---------------------------------------------------------------------------*/
  103. /* Flag manipulation macros */
  104. #define MTR_SET(node, flag) (node->flags |= (flag))
  105. #define MTR_RESET(node, flag) (node->flags &= ~ (flag))
  106. #define MTR_TEST(node, flag) (node->flags & (flag))
  107. /** \cond */
  108. /*---------------------------------------------------------------------------*/
  109. /* Function prototypes */
  110. /*---------------------------------------------------------------------------*/
  111. /** \endcond */
  112. #endif /* MTRINT_H_ */