mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2024-11-26 15:32:05 +00:00
ff4be24726
In some cases, the memory address of some variables may have 4 least significant bytes set to zero. Because we cast the pointer to int, we look only at 4 least significant bytes; the assertion may fail because 4 least significant bytes are 0. Change bh_assert implementation to cast the assert expr to int64_t and it works well with 64-bit architectures.
43 lines
983 B
C
43 lines
983 B
C
/*
|
|
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
*/
|
|
|
|
#ifndef _BH_ASSERT_H
|
|
#define _BH_ASSERT_H
|
|
|
|
#include "bh_platform.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#if BH_DEBUG != 0
|
|
void
|
|
bh_assert_internal(int64 v, const char *file_name, int line_number,
|
|
const char *expr_string);
|
|
#define bh_assert(expr) \
|
|
bh_assert_internal((int64)(uintptr_t)(expr), __FILE__, __LINE__, #expr)
|
|
#else
|
|
#define bh_assert(expr) (void)0
|
|
#endif /* end of BH_DEBUG */
|
|
|
|
#if !defined(__has_extension)
|
|
#define __has_extension(a) 0
|
|
#endif
|
|
|
|
#if __STDC_VERSION__ >= 201112L \
|
|
|| (defined(__GNUC__) && __GNUC__ * 0x100 + __GNUC_MINOR__ >= 0x406) \
|
|
|| __has_extension(c_static_assert)
|
|
|
|
#define bh_static_assert(expr) _Static_assert(expr, #expr)
|
|
#else
|
|
#define bh_static_assert(expr) /* nothing */
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* end of _BH_ASSERT_H */
|