bh_assert.h 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _BH_ASSERT_H
  6. #define _BH_ASSERT_H
  7. #include "bh_platform.h"
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #if BH_DEBUG != 0
  12. void
  13. bh_assert_internal(int64 v, const char *file_name, int line_number,
  14. const char *expr_string);
  15. #define bh_assert(expr) \
  16. bh_assert_internal((int64)(uintptr_t)(expr), __FILE__, __LINE__, #expr)
  17. #else
  18. #define bh_assert(expr) (void)0
  19. #endif /* end of BH_DEBUG */
  20. #if !defined(__has_extension)
  21. #define __has_extension(a) 0
  22. #endif
  23. #if __STDC_VERSION__ >= 201112L \
  24. || (defined(__GNUC__) && __GNUC__ * 0x100 + __GNUC_MINOR__ >= 0x406) \
  25. || __has_extension(c_static_assert)
  26. #define bh_static_assert(expr) _Static_assert(expr, #expr)
  27. #else
  28. #define bh_static_assert(expr) /* nothing */
  29. #endif
  30. #ifdef __cplusplus
  31. }
  32. #endif
  33. #endif /* end of _BH_ASSERT_H */