diff --git a/crates/c/src/lib.rs b/crates/c/src/lib.rs index 99eb5c689..c9e996137 100644 --- a/crates/c/src/lib.rs +++ b/crates/c/src/lib.rs @@ -893,7 +893,12 @@ pub fn c_func_name( !in_import, renamed_interfaces, )), - None => name.push_str(&world.to_snake_case()), + None => { + if !in_import { + name.push_str("exports_"); + } + name.push_str(&world.to_snake_case()); + } } name.push_str("_"); name.push_str(&func.name.to_snake_case().replace('.', "_")); diff --git a/tests/codegen/import-export-same-func.wit b/tests/codegen/import-export-same-func.wit new file mode 100644 index 000000000..93f45e1cf --- /dev/null +++ b/tests/codegen/import-export-same-func.wit @@ -0,0 +1,6 @@ +package green:blue; + +world my-world { + import purple: func(); + export purple: func(); +} diff --git a/tests/runtime/flavorful/wasm.c b/tests/runtime/flavorful/wasm.c index 6cb17e656..e448d0d29 100644 --- a/tests/runtime/flavorful/wasm.c +++ b/tests/runtime/flavorful/wasm.c @@ -3,7 +3,7 @@ #include #include -void flavorful_test_imports() { +void exports_flavorful_test_imports() { { test_flavorful_test_list_in_record1_t a; flavorful_string_set(&a.a, "list_in_record1"); diff --git a/tests/runtime/lists/wasm.c b/tests/runtime/lists/wasm.c index d69a84770..253dc586d 100644 --- a/tests/runtime/lists/wasm.c +++ b/tests/runtime/lists/wasm.c @@ -7,11 +7,11 @@ #include #include -uint32_t lists_allocated_bytes(void) { +uint32_t exports_lists_allocated_bytes(void) { return 0; } -void lists_test_imports() { +void exports_lists_test_imports() { { uint8_t list[] = {}; lists_list_u8_t a; diff --git a/tests/runtime/many_arguments/wasm.c b/tests/runtime/many_arguments/wasm.c index e96692cc9..64e456f9d 100644 --- a/tests/runtime/many_arguments/wasm.c +++ b/tests/runtime/many_arguments/wasm.c @@ -3,7 +3,7 @@ #include #include -void many_arguments_many_arguments( +void exports_many_arguments_many_arguments( uint64_t a1, uint64_t a2, uint64_t a3, diff --git a/tests/runtime/numbers/wasm.c b/tests/runtime/numbers/wasm.c index e827f2597..bc62d3b9c 100644 --- a/tests/runtime/numbers/wasm.c +++ b/tests/runtime/numbers/wasm.c @@ -58,7 +58,7 @@ uint32_t exports_test_numbers_test_get_scalar(void) { } -void numbers_test_imports() { +void exports_numbers_test_imports() { assert(test_numbers_test_roundtrip_u8(1) == 1); assert(test_numbers_test_roundtrip_u8(0) == 0); assert(test_numbers_test_roundtrip_u8(UCHAR_MAX) == UCHAR_MAX); diff --git a/tests/runtime/records/wasm.c b/tests/runtime/records/wasm.c index 2cfcfaccf..6bbb0f32e 100644 --- a/tests/runtime/records/wasm.c +++ b/tests/runtime/records/wasm.c @@ -1,7 +1,7 @@ #include #include -void records_test_imports() { +void exports_records_test_imports() { { records_tuple2_u8_u16_t ret; test_records_test_multiple_results(&ret); diff --git a/tests/runtime/resource_borrow_simple/wasm.c b/tests/runtime/resource_borrow_simple/wasm.c index c98eb3a2e..8489299bd 100644 --- a/tests/runtime/resource_borrow_simple/wasm.c +++ b/tests/runtime/resource_borrow_simple/wasm.c @@ -1,7 +1,7 @@ #include #include -void resource_borrow_simple_test_imports(void) { +void exports_resource_borrow_simple_test_imports(void) { resource_borrow_simple_own_r_t r = resource_borrow_simple_constructor_r(); resource_borrow_simple_borrow_r_t b = resource_borrow_simple_borrow_r(r); resource_borrow_simple_test(b); diff --git a/tests/runtime/resource_import_and_export/wasm.c b/tests/runtime/resource_import_and_export/wasm.c index b380edfd5..8ef886e29 100644 --- a/tests/runtime/resource_import_and_export/wasm.c +++ b/tests/runtime/resource_import_and_export/wasm.c @@ -12,7 +12,7 @@ struct exports_test_resource_import_and_export_test_thing_t { }; resource_import_and_export_own_thing_t -resource_import_and_export_toplevel_export(resource_import_and_export_own_thing_t a) { +exports_resource_import_and_export_toplevel_export(resource_import_and_export_own_thing_t a) { return resource_import_and_export_toplevel_import(a); } diff --git a/tests/runtime/smoke/wasm.c b/tests/runtime/smoke/wasm.c index 43f765a0b..e0173962a 100644 --- a/tests/runtime/smoke/wasm.c +++ b/tests/runtime/smoke/wasm.c @@ -1,7 +1,7 @@ #include #include -void smoke_thunk() { +void exports_smoke_thunk() { test_smoke_imports_thunk(); printf("howdy\n"); diff --git a/tests/runtime/strings/wasm_utf16.c b/tests/runtime/strings/wasm_utf16.c index 3c6d351f6..e5bfca459 100644 --- a/tests/runtime/strings/wasm_utf16.c +++ b/tests/runtime/strings/wasm_utf16.c @@ -14,7 +14,7 @@ void assert_str(strings_string_t* str, const char16_t* expected) { assert(memcmp(str->ptr, expected, expected_len * 2) == 0); } -void strings_test_imports() { +void exports_strings_test_imports() { strings_string_t str1; strings_string_set(&str1, u"latin utf16"); test_strings_imports_take_basic(&str1); @@ -25,11 +25,11 @@ void strings_test_imports() { strings_string_free(&str2); } -void strings_return_empty(strings_string_t *ret) { +void exports_strings_return_empty(strings_string_t *ret) { strings_string_dup(ret, u""); // Exercise cabi_realloc new_size = 0 } -void strings_roundtrip(strings_string_t *str, strings_string_t *ret) { +void exports_strings_roundtrip(strings_string_t *str, strings_string_t *ret) { assert(str->len > 0); ret->len = str->len; ret->ptr = (uint16_t *) malloc(ret->len * 2); diff --git a/tests/runtime/variants/wasm.c b/tests/runtime/variants/wasm.c index a2e7dacd4..01e2290ec 100644 --- a/tests/runtime/variants/wasm.c +++ b/tests/runtime/variants/wasm.c @@ -2,7 +2,7 @@ #include #include -void variants_test_imports() { +void exports_variants_test_imports() { { float a = 1; uint8_t r;