Skip to content

Commit

Permalink
Respond to review
Browse files Browse the repository at this point in the history
  • Loading branch information
keithw committed Nov 11, 2024
1 parent bffd4df commit d15bfb9
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/prebuilt/wasm2c_source_declarations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,18 @@ R"w2c_template(
)w2c_template"
R"w2c_template(#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
)w2c_template"
R"w2c_template(#else /* MSVC */
R"w2c_template(#elif defined(MSVC)
)w2c_template"
R"w2c_template(static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
)w2c_template"
R"w2c_template( return _addcarry_u64(0, a, b, resptr);
)w2c_template"
R"w2c_template(}
)w2c_template"
R"w2c_template(#else
)w2c_template"
R"w2c_template(#error "Missing implementation of __builtin_add_overflow or _addcarry_u64"
)w2c_template"
R"w2c_template(#endif
)w2c_template"
R"w2c_template(
Expand Down
4 changes: 3 additions & 1 deletion src/template/wasm2c.declarations.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,

#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
#else /* MSVC */
#elif defined(MSVC)
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
return _addcarry_u64(0, a, b, resptr);
}
#else
#error "Missing implementation of __builtin_add_overflow or _addcarry_u64"
#endif

#define RANGE_CHECK(mem, offset, len) \
Expand Down
4 changes: 3 additions & 1 deletion test/wasm2c/add.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,12 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
#else /* MSVC */
#elif defined(MSVC)
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
return _addcarry_u64(0, a, b, resptr);
}
#else
#error "Missing implementation of __builtin_add_overflow or _addcarry_u64"
#endif
#define RANGE_CHECK(mem, offset, len) \
Expand Down
4 changes: 3 additions & 1 deletion test/wasm2c/check-imports.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
#else /* MSVC */
#elif defined(MSVC)
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
return _addcarry_u64(0, a, b, resptr);
}
#else
#error "Missing implementation of __builtin_add_overflow or _addcarry_u64"
#endif
#define RANGE_CHECK(mem, offset, len) \
Expand Down
4 changes: 3 additions & 1 deletion test/wasm2c/export-names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
#else /* MSVC */
#elif defined(MSVC)
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
return _addcarry_u64(0, a, b, resptr);
}
#else
#error "Missing implementation of __builtin_add_overflow or _addcarry_u64"
#endif
#define RANGE_CHECK(mem, offset, len) \
Expand Down
4 changes: 3 additions & 1 deletion test/wasm2c/hello.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,12 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
#else /* MSVC */
#elif defined(MSVC)
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
return _addcarry_u64(0, a, b, resptr);
}
#else
#error "Missing implementation of __builtin_add_overflow or _addcarry_u64"
#endif
#define RANGE_CHECK(mem, offset, len) \
Expand Down
4 changes: 3 additions & 1 deletion test/wasm2c/minimal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,12 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
#else /* MSVC */
#elif defined(MSVC)
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
return _addcarry_u64(0, a, b, resptr);
}
#else
#error "Missing implementation of __builtin_add_overflow or _addcarry_u64"
#endif
#define RANGE_CHECK(mem, offset, len) \
Expand Down
4 changes: 3 additions & 1 deletion test/wasm2c/tail-calls.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,12 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
#else /* MSVC */
#elif defined(MSVC)
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
return _addcarry_u64(0, a, b, resptr);
}
#else
#error "Missing implementation of __builtin_add_overflow or _addcarry_u64"
#endif
#define RANGE_CHECK(mem, offset, len) \
Expand Down

0 comments on commit d15bfb9

Please sign in to comment.