debug.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // Debugging support implementation -*- C++ -*-
  2. // Copyright (C) 2003-2015 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file debug/debug.h
  21. * This file is a GNU debug extension to the Standard C++ Library.
  22. */
  23. #ifndef _GLIBCXX_DEBUG_MACRO_SWITCH_H
  24. #define _GLIBCXX_DEBUG_MACRO_SWITCH_H 1
  25. /** Macros and namespaces used by the implementation outside of debug
  26. * wrappers to verify certain properties. The __glibcxx_requires_xxx
  27. * macros are merely wrappers around the __glibcxx_check_xxx wrappers
  28. * when we are compiling with debug mode, but disappear when we are
  29. * in release mode so that there is no checking performed in, e.g.,
  30. * the standard library algorithms.
  31. */
  32. // Debug mode namespaces.
  33. /**
  34. * @namespace std::__debug
  35. * @brief GNU debug code, replaces standard behavior with debug behavior.
  36. */
  37. namespace std
  38. {
  39. namespace __debug { }
  40. }
  41. /** @namespace __gnu_debug
  42. * @brief GNU debug classes for public use.
  43. */
  44. namespace __gnu_debug
  45. {
  46. using namespace std::__debug;
  47. }
  48. #ifndef _GLIBCXX_DEBUG
  49. # define _GLIBCXX_DEBUG_ASSERT(_Condition)
  50. # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
  51. # define _GLIBCXX_DEBUG_ONLY(_Statement) ;
  52. # define __glibcxx_requires_cond(_Cond,_Msg)
  53. # define __glibcxx_requires_valid_range(_First,_Last)
  54. # define __glibcxx_requires_non_empty_range(_First,_Last)
  55. # define __glibcxx_requires_sorted(_First,_Last)
  56. # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
  57. # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2)
  58. # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred)
  59. # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value)
  60. # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value)
  61. # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred)
  62. # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred)
  63. # define __glibcxx_requires_heap(_First,_Last)
  64. # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
  65. # define __glibcxx_requires_nonempty()
  66. # define __glibcxx_requires_string(_String)
  67. # define __glibcxx_requires_string_len(_String,_Len)
  68. # define __glibcxx_requires_subscript(_N)
  69. #else
  70. # include <debug/macros.h>
  71. #define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition)
  72. #ifdef _GLIBCXX_DEBUG_PEDANTIC
  73. # define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)
  74. #else
  75. # define _GLIBCXX_DEBUG_PEDASSERT(_Condition)
  76. #endif
  77. # define _GLIBCXX_DEBUG_ONLY(_Statement) _Statement
  78. # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
  79. # define __glibcxx_requires_valid_range(_First,_Last) \
  80. __glibcxx_check_valid_range(_First,_Last)
  81. # define __glibcxx_requires_non_empty_range(_First,_Last) \
  82. __glibcxx_check_non_empty_range(_First,_Last)
  83. # define __glibcxx_requires_sorted(_First,_Last) \
  84. __glibcxx_check_sorted(_First,_Last)
  85. # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \
  86. __glibcxx_check_sorted_pred(_First,_Last,_Pred)
  87. # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) \
  88. __glibcxx_check_sorted_set(_First1,_Last1,_First2)
  89. # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
  90. __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred)
  91. # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value) \
  92. __glibcxx_check_partitioned_lower(_First,_Last,_Value)
  93. # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value) \
  94. __glibcxx_check_partitioned_upper(_First,_Last,_Value)
  95. # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
  96. __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred)
  97. # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
  98. __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred)
  99. # define __glibcxx_requires_heap(_First,_Last) \
  100. __glibcxx_check_heap(_First,_Last)
  101. # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
  102. __glibcxx_check_heap_pred(_First,_Last,_Pred)
  103. # define __glibcxx_requires_nonempty() __glibcxx_check_nonempty()
  104. # define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
  105. # define __glibcxx_requires_string_len(_String,_Len) \
  106. __glibcxx_check_string_len(_String,_Len)
  107. # define __glibcxx_requires_subscript(_N) __glibcxx_check_subscript(_N)
  108. # include <debug/functions.h>
  109. #endif
  110. #endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H