Skip to content

Commit 0411662

Browse files
committed
fixup: MSVC __builtin_expect shim for the cold-path hints
Windows MSVC build of upstream PR #4949 failed with `LNK2019: unresolved external symbol __builtin_expect` because `__builtin_expect` is a GCC/Clang builtin and MSVC has nothing equivalent. The branch-predictor hints are an optimization, not correctness, so the simplest portable fix is a no-op fallback gated on `!defined(__GNUC__) && !defined(__clang__)`. Lives at the top of `wasm_interp_fast.c` rather than in `bh_platform.h` to avoid touching the shared header for a local cold-path concern.
1 parent 231862a commit 0411662

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

core/iwasm/interpreter/wasm_interp_fast.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
#include "simde/wasm/simd128.h"
2626
#endif
2727

28+
/* MSVC has no `__builtin_expect`; the cold-path hints below are
29+
* GCC/Clang only. Provide a no-op fallback so the loop still
30+
* compiles on the Windows MSVC build. Branch-predictor hints are
31+
* an optimization, not correctness, so dropping them on MSVC is
32+
* fine. */
33+
#if !defined(__GNUC__) && !defined(__clang__)
34+
#define __builtin_expect(expr, expected) (expr)
35+
#endif
36+
2837
typedef int32 CellType_I32;
2938
typedef int64 CellType_I64;
3039
typedef float32 CellType_F32;

0 commit comments

Comments
 (0)