debug.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Debugging support implementation -*- C++ -*-
  2. // Copyright (C) 2003-2018 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. #include <debug/assertions.h>
  33. // Debug mode namespaces.
  34. /**
  35. * @namespace std::__debug
  36. * @brief GNU debug code, replaces standard behavior with debug behavior.
  37. */
  38. namespace std
  39. {
  40. namespace __debug { }
  41. }
  42. /** @namespace __gnu_debug
  43. * @brief GNU debug classes for public use.
  44. */
  45. namespace __gnu_debug
  46. {
  47. using namespace std::__debug;
  48. }
  49. #ifndef _GLIBCXX_DEBUG
  50. # define __glibcxx_requires_cond(_Cond,_Msg)
  51. # define __glibcxx_requires_valid_range(_First,_Last)
  52. # define __glibcxx_requires_sorted(_First,_Last)
  53. # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred)
  54. # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2)
  55. # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred)
  56. # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value)
  57. # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value)
  58. # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred)
  59. # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred)
  60. # define __glibcxx_requires_heap(_First,_Last)
  61. # define __glibcxx_requires_heap_pred(_First,_Last,_Pred)
  62. # define __glibcxx_requires_string(_String)
  63. # define __glibcxx_requires_string_len(_String,_Len)
  64. # define __glibcxx_requires_irreflexive(_First,_Last)
  65. # define __glibcxx_requires_irreflexive2(_First,_Last)
  66. # define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred)
  67. # define __glibcxx_requires_irreflexive_pred2(_First,_Last,_Pred)
  68. #else
  69. # include <debug/macros.h>
  70. # define __glibcxx_requires_cond(_Cond,_Msg) _GLIBCXX_DEBUG_VERIFY(_Cond,_Msg)
  71. # define __glibcxx_requires_valid_range(_First,_Last) \
  72. __glibcxx_check_valid_range(_First,_Last)
  73. # define __glibcxx_requires_sorted(_First,_Last) \
  74. __glibcxx_check_sorted(_First,_Last)
  75. # define __glibcxx_requires_sorted_pred(_First,_Last,_Pred) \
  76. __glibcxx_check_sorted_pred(_First,_Last,_Pred)
  77. # define __glibcxx_requires_sorted_set(_First1,_Last1,_First2) \
  78. __glibcxx_check_sorted_set(_First1,_Last1,_First2)
  79. # define __glibcxx_requires_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
  80. __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred)
  81. # define __glibcxx_requires_partitioned_lower(_First,_Last,_Value) \
  82. __glibcxx_check_partitioned_lower(_First,_Last,_Value)
  83. # define __glibcxx_requires_partitioned_upper(_First,_Last,_Value) \
  84. __glibcxx_check_partitioned_upper(_First,_Last,_Value)
  85. # define __glibcxx_requires_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
  86. __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred)
  87. # define __glibcxx_requires_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
  88. __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred)
  89. # define __glibcxx_requires_heap(_First,_Last) \
  90. __glibcxx_check_heap(_First,_Last)
  91. # define __glibcxx_requires_heap_pred(_First,_Last,_Pred) \
  92. __glibcxx_check_heap_pred(_First,_Last,_Pred)
  93. # define __glibcxx_requires_string(_String) __glibcxx_check_string(_String)
  94. # define __glibcxx_requires_string_len(_String,_Len) \
  95. __glibcxx_check_string_len(_String,_Len)
  96. # define __glibcxx_requires_irreflexive(_First,_Last) \
  97. __glibcxx_check_irreflexive(_First,_Last)
  98. # define __glibcxx_requires_irreflexive2(_First,_Last) \
  99. __glibcxx_check_irreflexive2(_First,_Last)
  100. # define __glibcxx_requires_irreflexive_pred(_First,_Last,_Pred) \
  101. __glibcxx_check_irreflexive_pred(_First,_Last,_Pred)
  102. # define __glibcxx_requires_irreflexive_pred2(_First,_Last,_Pred) \
  103. __glibcxx_check_irreflexive_pred2(_First,_Last,_Pred)
  104. # include <debug/functions.h>
  105. #endif
  106. #endif // _GLIBCXX_DEBUG_MACRO_SWITCH_H