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 12, 2024
1 parent 64a616d commit 487cb8a
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions src/prebuilt/wasm2c_source_declarations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,24 @@ R"w2c_template( (CHECK_CALL_INDIRECT(table, ft, x), \
R"w2c_template( DO_CALL_INDIRECT(table, t, x, __VA_ARGS__))
)w2c_template"
R"w2c_template(
#if __has_builtin(__builtin_add_overflow)
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
)w2c_template"
R"w2c_template(#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
R"w2c_template(#if __has_builtin(__builtin_add_overflow)
)w2c_template"
R"w2c_template(#elif defined(_MSC_VER)
R"w2c_template( return __builtin_add_overflow(a, b, resptr);
)w2c_template"
R"w2c_template(static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
R"w2c_template(#elif defined(_MSC_VER)
)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(}
)w2c_template"
R"w2c_template(
#define RANGE_CHECK(mem, offset, len) \
)w2c_template"
Expand Down
6 changes: 3 additions & 3 deletions src/template/wasm2c.declarations.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
(CHECK_CALL_INDIRECT(table, ft, x), \
DO_CALL_INDIRECT(table, t, x, __VA_ARGS__))

static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
return __builtin_add_overflow(a, b, resptr);
#elif defined(_MSC_VER)
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) \
do { \
Expand Down
6 changes: 3 additions & 3 deletions test/wasm2c/add.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
(CHECK_CALL_INDIRECT(table, ft, x), \
DO_CALL_INDIRECT(table, t, x, __VA_ARGS__))
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
return __builtin_add_overflow(a, b, resptr);
#elif defined(_MSC_VER)
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) \
do { \
Expand Down
6 changes: 3 additions & 3 deletions test/wasm2c/check-imports.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
(CHECK_CALL_INDIRECT(table, ft, x), \
DO_CALL_INDIRECT(table, t, x, __VA_ARGS__))
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
return __builtin_add_overflow(a, b, resptr);
#elif defined(_MSC_VER)
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) \
do { \
Expand Down
6 changes: 3 additions & 3 deletions test/wasm2c/export-names.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
(CHECK_CALL_INDIRECT(table, ft, x), \
DO_CALL_INDIRECT(table, t, x, __VA_ARGS__))
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
return __builtin_add_overflow(a, b, resptr);
#elif defined(_MSC_VER)
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) \
do { \
Expand Down
6 changes: 3 additions & 3 deletions test/wasm2c/hello.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
(CHECK_CALL_INDIRECT(table, ft, x), \
DO_CALL_INDIRECT(table, t, x, __VA_ARGS__))
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
return __builtin_add_overflow(a, b, resptr);
#elif defined(_MSC_VER)
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) \
do { \
Expand Down
6 changes: 3 additions & 3 deletions test/wasm2c/minimal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
(CHECK_CALL_INDIRECT(table, ft, x), \
DO_CALL_INDIRECT(table, t, x, __VA_ARGS__))
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
return __builtin_add_overflow(a, b, resptr);
#elif defined(_MSC_VER)
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) \
do { \
Expand Down
6 changes: 3 additions & 3 deletions test/wasm2c/tail-calls.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
(CHECK_CALL_INDIRECT(table, ft, x), \
DO_CALL_INDIRECT(table, t, x, __VA_ARGS__))
static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
return __builtin_add_overflow(a, b, resptr);
#elif defined(_MSC_VER)
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) \
do { \
Expand Down
6 changes: 3 additions & 3 deletions wasm2c/examples/fac/fac.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ static inline bool func_types_eq(const wasm_rt_func_type_t a,
(CHECK_CALL_INDIRECT(table, ft, x), \
DO_CALL_INDIRECT(table, t, x, __VA_ARGS__))

static inline bool add_overflow(uint64_t a, uint64_t b, uint64_t* resptr) {
#if __has_builtin(__builtin_add_overflow)
#define add_overflow(a, b, resptr) __builtin_add_overflow(a, b, resptr)
return __builtin_add_overflow(a, b, resptr);
#elif defined(_MSC_VER)
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) \
do { \
Expand Down

0 comments on commit 487cb8a

Please sign in to comment.