build.cc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Copyright 2021 gRPC authors.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. bool BuiltUnderValgrind() {
  15. #ifdef RUNNING_ON_VALGRIND
  16. return true;
  17. #else
  18. return false;
  19. #endif
  20. }
  21. bool BuiltUnderTsan() {
  22. #if defined(__has_feature)
  23. #if __has_feature(thread_sanitizer)
  24. return true;
  25. #else
  26. return false;
  27. #endif
  28. #else
  29. #ifdef THREAD_SANITIZER
  30. return true;
  31. #else
  32. return false;
  33. #endif
  34. #endif
  35. }
  36. bool BuiltUnderAsan() {
  37. #if defined(__has_feature)
  38. #if __has_feature(address_sanitizer)
  39. return true;
  40. #else
  41. return false;
  42. #endif
  43. #else
  44. #ifdef ADDRESS_SANITIZER
  45. return true;
  46. #else
  47. return false;
  48. #endif
  49. #endif
  50. }
  51. bool BuiltUnderMsan() {
  52. #if defined(__has_feature)
  53. #if __has_feature(memory_sanitizer)
  54. return true;
  55. #else
  56. return false;
  57. #endif
  58. #else
  59. #ifdef MEMORY_SANITIZER
  60. return true;
  61. #else
  62. return false;
  63. #endif
  64. #endif
  65. }
  66. bool BuiltUnderUbsan() {
  67. #ifdef GRPC_UBSAN
  68. return true;
  69. #else
  70. return false;
  71. #endif
  72. }