Skip to content

Commit

Permalink
Support "C-unwind" ABI
Browse files Browse the repository at this point in the history
Closes #864
  • Loading branch information
taeruh authored and emilio committed Sep 4, 2023
1 parent db6ccdd commit d8355da
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bindgen/utilities.rs
Expand Up @@ -263,7 +263,7 @@ 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 lit_string.value() == "C";
return matches!(lit_string.value().as_str(), "C" | "C-unwind");
}
}
false
Expand All @@ -280,7 +280,7 @@ impl SynAbiHelpers for Option<syn::Abi> {
impl SynAbiHelpers for syn::Abi {
fn is_c(&self) -> bool {
if let Some(ref lit_string) = self.name {
lit_string.value() == "C"
matches!(lit_string.value().as_str(), "C" | "C-unwind")
} else {
false
}
Expand Down
8 changes: 8 additions & 0 deletions tests/expectations/abi_string.c
@@ -0,0 +1,8 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

void c(void);

void c_unwind(void);
16 changes: 16 additions & 0 deletions tests/expectations/abi_string.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 c(void);

void c_unwind(void);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
13 changes: 13 additions & 0 deletions tests/expectations/abi_string.cpp
@@ -0,0 +1,13 @@
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>

extern "C" {

void c();

void c_unwind();

} // extern "C"
11 changes: 11 additions & 0 deletions tests/expectations/abi_string.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 c();

void c_unwind();
5 changes: 5 additions & 0 deletions tests/rust/abi_string.rs
@@ -0,0 +1,5 @@
#[no_mangle]
pub extern "C" fn c() {}

#[no_mangle]
pub extern "C-unwind" fn c_unwind() {}

0 comments on commit d8355da

Please sign in to comment.