From 487cb8a0bcd35bb9bc7befcb50fc6b5302d91bc3 Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Tue, 12 Nov 2024 11:16:36 -0700 Subject: [PATCH] Respond to review --- src/prebuilt/wasm2c_source_declarations.cc | 12 ++++++------ src/template/wasm2c.declarations.c | 6 +++--- test/wasm2c/add.txt | 6 +++--- test/wasm2c/check-imports.txt | 6 +++--- test/wasm2c/export-names.txt | 6 +++--- test/wasm2c/hello.txt | 6 +++--- test/wasm2c/minimal.txt | 6 +++--- test/wasm2c/tail-calls.txt | 6 +++--- wasm2c/examples/fac/fac.c | 6 +++--- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/prebuilt/wasm2c_source_declarations.cc b/src/prebuilt/wasm2c_source_declarations.cc index 9841120bb..db7ad6854 100644 --- a/src/prebuilt/wasm2c_source_declarations.cc +++ b/src/prebuilt/wasm2c_source_declarations.cc @@ -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" diff --git a/src/template/wasm2c.declarations.c b/src/template/wasm2c.declarations.c index 913787fd1..9a827c2f4 100644 --- a/src/template/wasm2c.declarations.c +++ b/src/template/wasm2c.declarations.c @@ -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 { \ diff --git a/test/wasm2c/add.txt b/test/wasm2c/add.txt index 5906e65d5..9db5e3901 100644 --- a/test/wasm2c/add.txt +++ b/test/wasm2c/add.txt @@ -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 { \ diff --git a/test/wasm2c/check-imports.txt b/test/wasm2c/check-imports.txt index 80ad6bc97..b69170daa 100644 --- a/test/wasm2c/check-imports.txt +++ b/test/wasm2c/check-imports.txt @@ -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 { \ diff --git a/test/wasm2c/export-names.txt b/test/wasm2c/export-names.txt index 86c50c593..2eb5e379a 100644 --- a/test/wasm2c/export-names.txt +++ b/test/wasm2c/export-names.txt @@ -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 { \ diff --git a/test/wasm2c/hello.txt b/test/wasm2c/hello.txt index e9c72f756..c3d1866d7 100644 --- a/test/wasm2c/hello.txt +++ b/test/wasm2c/hello.txt @@ -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 { \ diff --git a/test/wasm2c/minimal.txt b/test/wasm2c/minimal.txt index 1ac7290c7..a606cce25 100644 --- a/test/wasm2c/minimal.txt +++ b/test/wasm2c/minimal.txt @@ -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 { \ diff --git a/test/wasm2c/tail-calls.txt b/test/wasm2c/tail-calls.txt index 3431496c6..6a6f442c0 100644 --- a/test/wasm2c/tail-calls.txt +++ b/test/wasm2c/tail-calls.txt @@ -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 { \ diff --git a/wasm2c/examples/fac/fac.c b/wasm2c/examples/fac/fac.c index e216d4384..312bd8535 100644 --- a/wasm2c/examples/fac/fac.c +++ b/wasm2c/examples/fac/fac.c @@ -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 { \