Skip to content

Commit

Permalink
Allow name-mangling for the mbedtls_free, mbedtls_calloc and mbedtls_…
Browse files Browse the repository at this point in the history
…ssl_flush_output functions

According to the discussion in
rust-lang/rust-bindgen#1221 (comment),
the \u{1} is a hint to LLVM to avoid name-mangling but this might be required
on some platforms to link against the right name, e.g. on macOS.
  • Loading branch information
DrTobe authored and Taowyoo committed Jul 17, 2023
1 parent f38791f commit 5f0f8f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mbedtls/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ use core::mem::ManuallyDrop;
use mbedtls_sys::types::raw_types::c_void;

extern "C" {
#[link_name = concat!("\u{1}forward_mbedtls_free_", env!("RUST_MBEDTLS_METADATA_HASH"))]
#[link_name = concat!("forward_mbedtls_free_", env!("RUST_MBEDTLS_METADATA_HASH"))]
pub(crate) fn mbedtls_free(n: *mut mbedtls_sys::types::raw_types::c_void);
#[link_name = concat!("\u{1}forward_mbedtls_calloc_", env!("RUST_MBEDTLS_METADATA_HASH"))]
#[link_name = concat!("forward_mbedtls_calloc_", env!("RUST_MBEDTLS_METADATA_HASH"))]
pub(crate) fn mbedtls_calloc(n: mbedtls_sys::types::size_t, size: mbedtls_sys::types::size_t) -> *mut mbedtls_sys::types::raw_types::c_void;
}

Expand Down
4 changes: 2 additions & 2 deletions mbedtls/src/ssl/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ define!(
);

extern "C" {
// Since in mbedtld 3.X, upstream hide the `mbedtls_ssl_flush_output`, but we still need it for
// Since in mbedtls 3.X, upstream hide the `mbedtls_ssl_flush_output`, but we still need it for
// async here. Ref: https://github.com/Mbed-TLS/mbedtls/issues/4183
// So we mannully access it through defining it in `extern "C"` here
#[link_name = "\u{1}mbedtls_ssl_flush_output"]
#[link_name = "mbedtls_ssl_flush_output"]
fn ssl_flush_output(ssl: *mut ssl_context) -> c_int;
}

Expand Down

0 comments on commit 5f0f8f7

Please sign in to comment.