diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs index 6fe44750..67b93f25 100644 --- a/openssl-sys/src/lib.rs +++ b/openssl-sys/src/lib.rs @@ -344,6 +344,9 @@ extern { pub fn BIO_new_socket(sock: c_int, close_flag: c_int) -> *mut BIO; pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int; pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int; + #[cfg(ossl101)] + pub fn BIO_new_mem_buf(buf: *mut c_void, len: c_int) -> *mut BIO; + #[cfg(not(ossl101))] pub fn BIO_new_mem_buf(buf: *const c_void, len: c_int) -> *mut BIO; pub fn BIO_set_flags(b: *mut BIO, flags: c_int); pub fn BIO_clear_flags(b: *mut BIO, flags: c_int); diff --git a/openssl/src/bio.rs b/openssl/src/bio.rs index 0d82a6c3..22d2cee3 100644 --- a/openssl/src/bio.rs +++ b/openssl/src/bio.rs @@ -22,7 +22,7 @@ impl<'a> MemBioSlice<'a> { assert!(buf.len() <= c_int::max_value() as usize); let bio = unsafe { - try_ssl_null!(ffi::BIO_new_mem_buf(buf.as_ptr() as *const _, buf.len() as c_int)) + try_ssl_null!(BIO_new_mem_buf(buf.as_ptr() as *const _, buf.len() as c_int)) }; Ok(MemBioSlice(bio, PhantomData)) @@ -65,3 +65,12 @@ impl MemBio { } } } + +#[cfg(not(ossl101))] +use ffi::BIO_new_mem_buf; + +#[cfg(ossl101)] +#[allow(bad_style)] +unsafe fn BIO_new_mem_buf(buf: *const ::libc::c_void, len: ::libc::c_int) -> *mut ffi::BIO { + ffi::BIO_new_mem_buf(buf as *mut _, len) +} diff --git a/systest/build.rs b/systest/build.rs index 94c5534e..8fac5536 100644 --- a/systest/build.rs +++ b/systest/build.rs @@ -81,10 +81,6 @@ fn main() { s == "X509V3_EXT_conf_nid" || // weird lhash first param s == "X509V3_EXT_conf" || // weird lhash first param - // one parameter is `const` in OpenSSL 1.0.1, no need for a new - // definition or a new file here. - (s == "BIO_new_mem_buf" && env::var("DEP_OPENSSL_IS_101").is_ok()) || - // Skip some functions with function pointers on windows, not entirely // sure how to get them to work out... (target.contains("windows") && {