Check for CMSE ABI's as well
diff --git a/src/bindgen/parser.rs b/src/bindgen/parser.rs index af1b202..26c25e4 100644 --- a/src/bindgen/parser.rs +++ b/src/bindgen/parser.rs
@@ -728,7 +728,7 @@ items.join("::") }; - let is_extern_c = sig.abi.is_omitted() || sig.abi.is_c(); + let is_extern_c = sig.abi.is_omitted() || sig.abi.is_c() || sig.abi.is_cmse(); let exported_name = named_symbol.exported_name(); match (is_extern_c, exported_name) {
diff --git a/src/bindgen/utilities.rs b/src/bindgen/utilities.rs index 8f0763b..de61b2e 100644 --- a/src/bindgen/utilities.rs +++ b/src/bindgen/utilities.rs
@@ -384,24 +384,19 @@ /// Helper function for accessing Abi information pub trait SynAbiHelpers { fn is_c(&self) -> bool; + fn is_cmse(&self) -> bool; fn is_omitted(&self) -> bool; } impl SynAbiHelpers for Option<syn::Abi> { fn is_c(&self) -> bool { - if let Some(ref abi) = *self { - if let Some(ref lit_string) = abi.name { - return matches!(lit_string.value().as_str(), "C" | "C-unwind"); - } - } - false + self.as_ref().is_some_and(|abi| abi.is_c()) + } + fn is_cmse(&self) -> bool { + self.as_ref().is_some_and(|abi| abi.is_cmse()) } fn is_omitted(&self) -> bool { - if let Some(ref abi) = *self { - abi.name.is_none() - } else { - false - } + self.as_ref().is_some_and(|abi| abi.is_omitted()) } } @@ -413,6 +408,16 @@ false } } + fn is_cmse(&self) -> bool { + if let Some(ref lit_string) = self.name { + matches!( + lit_string.value().as_str(), + "cmse-nonsecure-entry" | "cmse-nonsecure-call" + ) + } else { + false + } + } fn is_omitted(&self) -> bool { self.name.is_none() }
diff --git a/tests/expectations-symbols/cmse.c.sym b/tests/expectations-symbols/cmse.c.sym new file mode 100644 index 0000000..5d8dd39 --- /dev/null +++ b/tests/expectations-symbols/cmse.c.sym
@@ -0,0 +1,4 @@ +{ +foo; +bar; +}; \ No newline at end of file
diff --git a/tests/expectations/cmse.c b/tests/expectations/cmse.c new file mode 100644 index 0000000..12d24d8 --- /dev/null +++ b/tests/expectations/cmse.c
@@ -0,0 +1,8 @@ +#include <stdarg.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdlib.h> + +void foo(void); + +void bar(void);
diff --git a/tests/expectations/cmse.compat.c b/tests/expectations/cmse.compat.c new file mode 100644 index 0000000..f9da637 --- /dev/null +++ b/tests/expectations/cmse.compat.c
@@ -0,0 +1,16 @@ +#include <stdarg.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdlib.h> + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +void foo(void); + +void bar(void); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus
diff --git a/tests/expectations/cmse.cpp b/tests/expectations/cmse.cpp new file mode 100644 index 0000000..f302595 --- /dev/null +++ b/tests/expectations/cmse.cpp
@@ -0,0 +1,13 @@ +#include <cstdarg> +#include <cstdint> +#include <cstdlib> +#include <ostream> +#include <new> + +extern "C" { + +void foo(); + +void bar(); + +} // extern "C"
diff --git a/tests/expectations/cmse.pyx b/tests/expectations/cmse.pyx new file mode 100644 index 0000000..51d33db --- /dev/null +++ b/tests/expectations/cmse.pyx
@@ -0,0 +1,11 @@ +from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t +from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t +cdef extern from *: + ctypedef bint bool + ctypedef struct va_list + +cdef extern from *: + + void foo(); + + void bar();
diff --git a/tests/rust/cmse.rs b/tests/rust/cmse.rs new file mode 100644 index 0000000..e5878f3 --- /dev/null +++ b/tests/rust/cmse.rs
@@ -0,0 +1,5 @@ +#[no_mangle] +pub extern "cmse-nonsecure-entry" fn foo() {} + +#[no_mangle] +pub extern "cmse-nonsecure-call" fn bar() {}