Bug 1945933 - build(rust): upgrade libloading 0.8.3 → 0.8.6 r=supply-chain-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D242022
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -3529,9 +3529,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
version = "0.8.3"
|
version = "0.8.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-targets",
|
"windows-targets",
|
||||||
|
|||||||
@@ -3077,6 +3077,11 @@ who = "Erich Gubler <erichdongubler@gmail.com>"
|
|||||||
criteria = "safe-to-deploy"
|
criteria = "safe-to-deploy"
|
||||||
delta = "0.7.4 -> 0.8.3"
|
delta = "0.7.4 -> 0.8.3"
|
||||||
|
|
||||||
|
[[audits.libloading]]
|
||||||
|
who = "Erich Gubler <erichdongubler@gmail.com>"
|
||||||
|
criteria = "safe-to-deploy"
|
||||||
|
delta = "0.8.3 -> 0.8.6"
|
||||||
|
|
||||||
[[audits.libm]]
|
[[audits.libm]]
|
||||||
who = "Makoto Kato <m_kato@ga2.so-net.ne.jp>"
|
who = "Makoto Kato <m_kato@ga2.so-net.ne.jp>"
|
||||||
criteria = "safe-to-deploy"
|
criteria = "safe-to-deploy"
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"files":{"Cargo.toml":"d97d9cdce69985cab52ba027b089854906d4cf653d581e9742530a536b4599fc","LICENSE":"b29f8b01452350c20dd1af16ef83b598fea3053578ccc1c7a0ef40e57be2620f","README.mkd":"707e1cae9fa4b691ce5cb8a3976573158fc60b67cb89948f8f5d51c5908bd0a8","src/changelog.rs":"e7c18ebb9be9624b64bcca3f39d714084cbbaa2ffbc35bfc033967b81be1af66","src/error.rs":"488004e68022adba1002c95d1c8f568fdf1f7bc88aedb6a0f5e31a3dab6f8509","src/lib.rs":"0142a630bb27d1443a8a79d1d5559ea10e859d587442c596d2be7d837507afa0","src/os/mod.rs":"6c59ef8c1120953ae6b6c32f27766c643ca90d85075c49c3545d2fe1ed82cedd","src/os/unix/consts.rs":"a1f98372a58acc6d00a1df19550e0593ede60a53f2aa3ff26cf678cf1015594c","src/os/unix/mod.rs":"15e284c70b61c2728cdf312c2c8740d1671a53dbc7161d8ad5c8a909416644cc","src/os/windows/mod.rs":"8a8792569d43140d982edd6d401abb82023894eb02f2eeba321ee9887568cf3b","src/safe.rs":"b0dc1cb5c8e0216e365063b5e84218b2377bb7a62714fca9a6215a22a7bc58b8","src/test_helpers.rs":"201403e143e5b3204864124cd38067cf8813d5273dc1a9099288a9dc4bdd15b6","src/util.rs":"0b6dcfb9eafff2d87966460ef6b1b99980f888813037e787ed92deee602f8c2b","tests/constants.rs":"4778c062605ed22238c1bed16de4c076d0857282f090f36e6d985dafb7b4544d","tests/functions.rs":"c3d4770704de40e9592cfd109cf506e6b04f0738d8a1ee02ec858b4fa4632a2b","tests/library_filename.rs":"b1481f0bb374687c5f24e25113426d2a95f08a45fb8bc41a41e8702bd5a7b4bf","tests/markers.rs":"0ebc8f807b92e39452d35732988012cdca7ce96231c57eaac9c3f4217225ad39","tests/nagisa32.dll":"5c69b2bd9c8a6ad04165c221075fc9fade1dd66ca697399ace528a5a62328e36","tests/nagisa64.dll":"e20b95e3036f3289421abd100760874d4f455afd33c3b5b64fec56b191f7d477","tests/windows.rs":"35584a46658b305cd539712d3ba3c21fe7a130fd693aa1389e4886a67625d532"},"package":"0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"}
|
{"files":{"Cargo.toml":"d4cf414be22ce0ddce103d5896f58c24c472910d48fea40490b084802869656d","LICENSE":"b29f8b01452350c20dd1af16ef83b598fea3053578ccc1c7a0ef40e57be2620f","README.mkd":"707e1cae9fa4b691ce5cb8a3976573158fc60b67cb89948f8f5d51c5908bd0a8","src/changelog.rs":"e13320d16739631d85a12f69acebc284a8ae008030c70cd70134e2d6465b0991","src/error.rs":"b459ce196d2bb449320c8747e80e00af3b898ee8ff66f758acf79f4923458396","src/lib.rs":"0142a630bb27d1443a8a79d1d5559ea10e859d587442c596d2be7d837507afa0","src/os/mod.rs":"6c59ef8c1120953ae6b6c32f27766c643ca90d85075c49c3545d2fe1ed82cedd","src/os/unix/consts.rs":"e726edbfe8295ac7053b6a8082b2c9f1deb32d24000301b69f185c45aa3bcff5","src/os/unix/mod.rs":"26bfefa0a41b67fb0c24aff5be012858cbf323c98aa1d619c63dac92211f3b17","src/os/windows/mod.rs":"85ab53fad612d8e29eac4ab23904dab6698a81662afbf8be5b5a8c0f0327a634","src/safe.rs":"0dc4c28f22e14832fb1a0ee003a66845dc5d5c6ecce2288e386e64ed9989e027","src/test_helpers.rs":"201403e143e5b3204864124cd38067cf8813d5273dc1a9099288a9dc4bdd15b6","src/util.rs":"0b6dcfb9eafff2d87966460ef6b1b99980f888813037e787ed92deee602f8c2b","tests/constants.rs":"4778c062605ed22238c1bed16de4c076d0857282f090f36e6d985dafb7b4544d","tests/functions.rs":"5ed6816841ff27e2d2ec2f9eb2a326e069e4d535b516f6377470910cf6c4a53b","tests/library_filename.rs":"b1481f0bb374687c5f24e25113426d2a95f08a45fb8bc41a41e8702bd5a7b4bf","tests/markers.rs":"0ebc8f807b92e39452d35732988012cdca7ce96231c57eaac9c3f4217225ad39","tests/nagisa32.dll":"5c69b2bd9c8a6ad04165c221075fc9fade1dd66ca697399ace528a5a62328e36","tests/nagisa64.dll":"e20b95e3036f3289421abd100760874d4f455afd33c3b5b64fec56b191f7d477","tests/windows.rs":"3c0a589014b3bef329bb12240d5622d2d7becd7d60ca022f78382c054e34bc07"},"package":"fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"}
|
||||||
9
third_party/rust/libloading/Cargo.toml
vendored
9
third_party/rust/libloading/Cargo.toml
vendored
@@ -10,9 +10,10 @@
|
|||||||
# See Cargo.toml.orig for the original contents.
|
# See Cargo.toml.orig for the original contents.
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
|
edition = "2015"
|
||||||
rust-version = "1.56.0"
|
rust-version = "1.56.0"
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
version = "0.8.3"
|
version = "0.8.6"
|
||||||
authors = ["Simonas Kazlauskas <libloading@kazlauskas.me>"]
|
authors = ["Simonas Kazlauskas <libloading@kazlauskas.me>"]
|
||||||
description = "Bindings around the platform's dynamic library loading primitives with greatly improved memory safety."
|
description = "Bindings around the platform's dynamic library loading primitives with greatly improved memory safety."
|
||||||
documentation = "https://docs.rs/libloading/"
|
documentation = "https://docs.rs/libloading/"
|
||||||
@@ -47,5 +48,9 @@ version = "1"
|
|||||||
version = ">=0.48, <0.53"
|
version = ">=0.48, <0.53"
|
||||||
|
|
||||||
[target."cfg(windows)".dev-dependencies.windows-sys]
|
[target."cfg(windows)".dev-dependencies.windows-sys]
|
||||||
version = "0.52"
|
version = ">=0.52,<0.59"
|
||||||
features = ["Win32_Foundation"]
|
features = ["Win32_Foundation"]
|
||||||
|
|
||||||
|
[lints.rust.unexpected_cfgs]
|
||||||
|
level = "warn"
|
||||||
|
priority = 0
|
||||||
|
|||||||
14
third_party/rust/libloading/src/changelog.rs
vendored
14
third_party/rust/libloading/src/changelog.rs
vendored
@@ -1,5 +1,13 @@
|
|||||||
//! The change log.
|
//! The change log.
|
||||||
|
|
||||||
|
|
||||||
|
/// Release 0.8.4 (2024-06-23)
|
||||||
|
///
|
||||||
|
/// ## Non-breaking changes
|
||||||
|
///
|
||||||
|
/// Compilation when targeting Apple's visionos, watchos and tvos targets has been fixed.
|
||||||
|
pub mod r0_8_4 {}
|
||||||
|
|
||||||
/// Release 0.8.3 (2024-03-05)
|
/// Release 0.8.3 (2024-03-05)
|
||||||
///
|
///
|
||||||
/// ## Non-breaking changes
|
/// ## Non-breaking changes
|
||||||
@@ -124,7 +132,7 @@ pub mod r0_7_1 {}
|
|||||||
/// Various executable and shared library formats define conventions and machinery to execute
|
/// Various executable and shared library formats define conventions and machinery to execute
|
||||||
/// arbitrary code when a program or a shared library is loaded. On systems using the PE format
|
/// arbitrary code when a program or a shared library is loaded. On systems using the PE format
|
||||||
/// (e.g. Windows) this is available via the optional `DllMain` initializer. Various systems
|
/// (e.g. Windows) this is available via the optional `DllMain` initializer. Various systems
|
||||||
/// utilizing the ELF format take a sightly different approach of maintaining an array of function
|
/// utilizing the ELF format take a slightly different approach of maintaining an array of function
|
||||||
/// pointers in the `.init_array` section. A very similar mechanism exists on systems that utilize
|
/// pointers in the `.init_array` section. A very similar mechanism exists on systems that utilize
|
||||||
/// the Mach-O format.
|
/// the Mach-O format.
|
||||||
///
|
///
|
||||||
@@ -194,8 +202,8 @@ pub mod r0_7_0 {}
|
|||||||
/// Release 0.6.7 (2021-01-14)
|
/// Release 0.6.7 (2021-01-14)
|
||||||
///
|
///
|
||||||
/// * Added a [`os::windows::Library::open_already_loaded`] to obtain a handle to a library that
|
/// * Added a [`os::windows::Library::open_already_loaded`] to obtain a handle to a library that
|
||||||
/// must already be loaded. There is no portable equivalent for all UNIX targets. Users who do not
|
/// must already be loaded. There is no portable equivalent for all UNIX targets. Users who do
|
||||||
/// care about portability across UNIX platforms may use [`os::unix::Library::open`] with
|
/// not care about portability across UNIX platforms may use [`os::unix::Library::open`] with
|
||||||
/// `libc::RTLD_NOLOAD`;
|
/// `libc::RTLD_NOLOAD`;
|
||||||
///
|
///
|
||||||
/// [`os::windows::Library::open_already_loaded`]: crate::os::windows::Library::open_already_loaded
|
/// [`os::windows::Library::open_already_loaded`]: crate::os::windows::Library::open_already_loaded
|
||||||
|
|||||||
1
third_party/rust/libloading/src/error.rs
vendored
1
third_party/rust/libloading/src/error.rs
vendored
@@ -98,6 +98,7 @@ impl std::error::Error for Error {
|
|||||||
CreateCString { ref source } => Some(source),
|
CreateCString { ref source } => Some(source),
|
||||||
CreateCStringWithTrailing { ref source } => Some(source),
|
CreateCStringWithTrailing { ref source } => Some(source),
|
||||||
LoadLibraryExW { ref source } => Some(&source.0),
|
LoadLibraryExW { ref source } => Some(&source.0),
|
||||||
|
GetModuleHandleExW { ref source } => Some(&source.0),
|
||||||
GetProcAddress { ref source } => Some(&source.0),
|
GetProcAddress { ref source } => Some(&source.0),
|
||||||
FreeLibrary { ref source } => Some(&source.0),
|
FreeLibrary { ref source } => Some(&source.0),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|||||||
@@ -69,6 +69,10 @@ mod posix {
|
|||||||
|
|
||||||
target_os = "macos",
|
target_os = "macos",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
|
target_os = "tvos",
|
||||||
|
target_os = "visionos",
|
||||||
|
target_os = "watchos",
|
||||||
|
|
||||||
target_os = "freebsd",
|
target_os = "freebsd",
|
||||||
target_os = "dragonfly",
|
target_os = "dragonfly",
|
||||||
target_os = "openbsd",
|
target_os = "openbsd",
|
||||||
@@ -103,6 +107,10 @@ mod posix {
|
|||||||
|
|
||||||
target_os = "macos",
|
target_os = "macos",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
|
target_os = "tvos",
|
||||||
|
target_os = "visionos",
|
||||||
|
target_os = "watchos",
|
||||||
|
|
||||||
target_os = "freebsd",
|
target_os = "freebsd",
|
||||||
target_os = "dragonfly",
|
target_os = "dragonfly",
|
||||||
target_os = "openbsd",
|
target_os = "openbsd",
|
||||||
@@ -147,6 +155,9 @@ mod posix {
|
|||||||
} else if #[cfg(any(
|
} else if #[cfg(any(
|
||||||
target_os = "macos",
|
target_os = "macos",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
|
target_os = "tvos",
|
||||||
|
target_os = "visionos",
|
||||||
|
target_os = "watchos",
|
||||||
))] {
|
))] {
|
||||||
pub(super) const RTLD_GLOBAL: c_int = 8;
|
pub(super) const RTLD_GLOBAL: c_int = 8;
|
||||||
} else if #[cfg(any(
|
} else if #[cfg(any(
|
||||||
@@ -188,6 +199,9 @@ mod posix {
|
|||||||
} else if #[cfg(any(
|
} else if #[cfg(any(
|
||||||
target_os = "macos",
|
target_os = "macos",
|
||||||
target_os = "ios",
|
target_os = "ios",
|
||||||
|
target_os = "tvos",
|
||||||
|
target_os = "visionos",
|
||||||
|
target_os = "watchos",
|
||||||
))] {
|
))] {
|
||||||
pub(super) const RTLD_LOCAL: c_int = 4;
|
pub(super) const RTLD_LOCAL: c_int = 4;
|
||||||
} else if #[cfg(any(
|
} else if #[cfg(any(
|
||||||
|
|||||||
@@ -396,6 +396,12 @@ impl<T> Symbol<T> {
|
|||||||
pub fn into_raw(self) -> *mut raw::c_void {
|
pub fn into_raw(self) -> *mut raw::c_void {
|
||||||
self.pointer
|
self.pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert the loaded `Symbol` into a raw pointer.
|
||||||
|
/// For unix this does the same as into_raw.
|
||||||
|
pub fn as_raw_ptr(self) -> *mut raw::c_void {
|
||||||
|
self.pointer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Symbol<Option<T>> {
|
impl<T> Symbol<Option<T>> {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use self::windows_imports::*;
|
|||||||
use util::{ensure_compatible_types, cstr_cow_from_bytes};
|
use util::{ensure_compatible_types, cstr_cow_from_bytes};
|
||||||
use std::ffi::{OsStr, OsString};
|
use std::ffi::{OsStr, OsString};
|
||||||
use std::{fmt, io, marker, mem, ptr};
|
use std::{fmt, io, marker, mem, ptr};
|
||||||
|
use std::os::raw;
|
||||||
|
|
||||||
/// The platform-specific counterpart of the cross-platform [`Library`](crate::Library).
|
/// The platform-specific counterpart of the cross-platform [`Library`](crate::Library).
|
||||||
pub struct Library(HMODULE);
|
pub struct Library(HMODULE);
|
||||||
@@ -299,6 +300,13 @@ impl<T> Symbol<T> {
|
|||||||
pub fn into_raw(self) -> FARPROC {
|
pub fn into_raw(self) -> FARPROC {
|
||||||
self.pointer
|
self.pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Convert the loaded `Symbol` into a raw pointer.
|
||||||
|
pub fn as_raw_ptr(self) -> *mut raw::c_void {
|
||||||
|
self.pointer
|
||||||
|
.map(|raw| raw as *mut raw::c_void)
|
||||||
|
.unwrap_or(std::ptr::null_mut())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Symbol<Option<T>> {
|
impl<T> Symbol<Option<T>> {
|
||||||
|
|||||||
33
third_party/rust/libloading/src/safe.rs
vendored
33
third_party/rust/libloading/src/safe.rs
vendored
@@ -1,14 +1,15 @@
|
|||||||
use super::Error;
|
|
||||||
#[cfg(libloading_docs)]
|
#[cfg(libloading_docs)]
|
||||||
use super::os::unix as imp; // the implementation used here doesn't matter particularly much...
|
use super::os::unix as imp; // the implementation used here doesn't matter particularly much...
|
||||||
#[cfg(all(not(libloading_docs), unix))]
|
#[cfg(all(not(libloading_docs), unix))]
|
||||||
use super::os::unix as imp;
|
use super::os::unix as imp;
|
||||||
#[cfg(all(not(libloading_docs), windows))]
|
#[cfg(all(not(libloading_docs), windows))]
|
||||||
use super::os::windows as imp;
|
use super::os::windows as imp;
|
||||||
|
use super::Error;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::marker;
|
use std::marker;
|
||||||
use std::ops;
|
use std::ops;
|
||||||
|
use std::os::raw;
|
||||||
|
|
||||||
/// A loaded dynamic library.
|
/// A loaded dynamic library.
|
||||||
#[cfg_attr(libloading_docs, doc(cfg(any(unix, windows))))]
|
#[cfg_attr(libloading_docs, doc(cfg(any(unix, windows))))]
|
||||||
@@ -144,7 +145,7 @@ impl Library {
|
|||||||
/// **awesome_variable = 42.0;
|
/// **awesome_variable = 42.0;
|
||||||
/// };
|
/// };
|
||||||
/// ```
|
/// ```
|
||||||
pub unsafe fn get<'lib, T>(&'lib self, symbol: &[u8]) -> Result<Symbol<'lib, T>, Error> {
|
pub unsafe fn get<T>(&self, symbol: &[u8]) -> Result<Symbol<T>, Error> {
|
||||||
self.0.get(symbol).map(|from| Symbol::from_raw(from, self))
|
self.0.get(symbol).map(|from| Symbol::from_raw(from, self))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,6 +250,25 @@ impl<'lib, T> Symbol<'lib, T> {
|
|||||||
pd: marker::PhantomData,
|
pd: marker::PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Try to convert the symbol into a raw pointer.
|
||||||
|
/// Success depends on the platform. Currently, this fn always succeeds and returns some.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// Using this function relinquishes all the lifetime guarantees. It is up to the developer to
|
||||||
|
/// ensure the resulting `Symbol` is not used past the lifetime of the `Library` this symbol
|
||||||
|
/// was loaded from.
|
||||||
|
pub unsafe fn try_as_raw_ptr(self) -> Option<*mut raw::c_void> {
|
||||||
|
Some(
|
||||||
|
#[allow(unused_unsafe)] // 1.56.0 compat
|
||||||
|
unsafe {
|
||||||
|
// SAFE: the calling function has the same soundness invariants as this callee.
|
||||||
|
self.into_raw()
|
||||||
|
}
|
||||||
|
.as_raw_ptr(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'lib, T> Symbol<'lib, Option<T>> {
|
impl<'lib, T> Symbol<'lib, Option<T>> {
|
||||||
@@ -282,18 +302,19 @@ impl<'lib, T> Clone for Symbol<'lib, T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: implement FnOnce for callable stuff instead.
|
// FIXME: implement FnOnce for callable stuff instead.
|
||||||
impl<'lib, T> ops::Deref for Symbol<'lib, T> {
|
impl<T> ops::Deref for Symbol<'_, T> {
|
||||||
type Target = T;
|
type Target = T;
|
||||||
fn deref(&self) -> &T {
|
fn deref(&self) -> &T {
|
||||||
ops::Deref::deref(&self.inner)
|
ops::Deref::deref(&self.inner)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'lib, T> fmt::Debug for Symbol<'lib, T> {
|
impl<T> fmt::Debug for Symbol<'_, T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
self.inner.fmt(f)
|
self.inner.fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<'lib, T: Send> Send for Symbol<'lib, T> {}
|
unsafe impl<T: Send> Send for Symbol<'_, T> {}
|
||||||
unsafe impl<'lib, T: Sync> Sync for Symbol<'lib, T> {}
|
unsafe impl<T: Sync> Sync for Symbol<'_, T> {}
|
||||||
|
|
||||||
|
|||||||
14
third_party/rust/libloading/tests/functions.rs
vendored
14
third_party/rust/libloading/tests/functions.rs
vendored
@@ -2,6 +2,7 @@
|
|||||||
extern crate windows_sys;
|
extern crate windows_sys;
|
||||||
|
|
||||||
extern crate libloading;
|
extern crate libloading;
|
||||||
|
use std::os::raw::c_void;
|
||||||
use libloading::{Library, Symbol};
|
use libloading::{Library, Symbol};
|
||||||
|
|
||||||
const TARGET_DIR: Option<&'static str> = option_env!("CARGO_TARGET_DIR");
|
const TARGET_DIR: Option<&'static str> = option_env!("CARGO_TARGET_DIR");
|
||||||
@@ -44,6 +45,19 @@ fn test_id_u32() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_try_into_ptr() {
|
||||||
|
make_helpers();
|
||||||
|
unsafe {
|
||||||
|
let lib = Library::new(lib_path()).unwrap();
|
||||||
|
let f: Symbol<unsafe extern "C" fn(u32) -> u32> = lib.get(b"test_identity_u32\0").unwrap();
|
||||||
|
let ptr: *mut c_void = f.try_as_raw_ptr().unwrap();
|
||||||
|
assert!(!ptr.is_null());
|
||||||
|
let ptr_casted : extern "C" fn(u32) -> u32 = std::mem::transmute(ptr);
|
||||||
|
assert_eq!(42, ptr_casted(42));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||||
struct S {
|
struct S {
|
||||||
|
|||||||
13
third_party/rust/libloading/tests/windows.rs
vendored
13
third_party/rust/libloading/tests/windows.rs
vendored
@@ -2,7 +2,7 @@
|
|||||||
extern crate libloading;
|
extern crate libloading;
|
||||||
use libloading::os::windows::*;
|
use libloading::os::windows::*;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
use std::os::raw::c_void;
|
||||||
// The ordinal DLL contains exactly one function (other than DllMain, that is) with ordinal number
|
// The ordinal DLL contains exactly one function (other than DllMain, that is) with ordinal number
|
||||||
// 1. This function has the sugnature `fn() -> *const c_char` and returns a string "bunny\0" (in
|
// 1. This function has the sugnature `fn() -> *const c_char` and returns a string "bunny\0" (in
|
||||||
// reference to WindowsBunny).
|
// reference to WindowsBunny).
|
||||||
@@ -37,6 +37,17 @@ fn test_ordinal() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(target_arch="x86", target_arch="x86_64"))]
|
||||||
|
#[test]
|
||||||
|
fn test_try_into_ptr() {
|
||||||
|
let lib = load_ordinal_lib();
|
||||||
|
unsafe {
|
||||||
|
let windows: Symbol<unsafe fn() -> *const i8> = lib.get_ordinal(1).expect("function");
|
||||||
|
let ptr : *mut c_void = windows.as_raw_ptr();
|
||||||
|
assert!(!ptr.is_null());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(any(target_arch="x86", target_arch="x86_64"))]
|
#[cfg(any(target_arch="x86", target_arch="x86_64"))]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ordinal_missing_fails() {
|
fn test_ordinal_missing_fails() {
|
||||||
|
|||||||
Reference in New Issue
Block a user