summaryrefslogtreecommitdiffstats
path: root/vendor/libloading
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/libloading')
-rw-r--r--vendor/libloading/.cargo-checksum.json2
-rw-r--r--vendor/libloading/Cargo.toml23
-rw-r--r--vendor/libloading/src/changelog.rs9
-rw-r--r--vendor/libloading/src/os/unix/consts.rs7
-rw-r--r--vendor/libloading/src/os/unix/mod.rs4
-rw-r--r--vendor/libloading/src/os/windows/mod.rs6
-rw-r--r--vendor/libloading/tests/functions.rs133
7 files changed, 119 insertions, 65 deletions
diff --git a/vendor/libloading/.cargo-checksum.json b/vendor/libloading/.cargo-checksum.json
index 611fc2748..04164017d 100644
--- a/vendor/libloading/.cargo-checksum.json
+++ b/vendor/libloading/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"e46195f62deca2f1fa63c19e754fb9eca0e0469d624e2ff5ac33f9d2bb0c67bf","LICENSE":"b29f8b01452350c20dd1af16ef83b598fea3053578ccc1c7a0ef40e57be2620f","README.mkd":"973a5fa332a8f33abc73ffc0ed509f81c66dbd681d8f50969cac32cdfe16ecb2","src/changelog.rs":"2c7cf7025d8f44a7c145852a0497934ae40d317cdd03de6284e36cd0d4774003","src/error.rs":"156c53e299e8f1cd4694b277a5d92772a8a9e7ec4004bae067367f4c2502de8b","src/lib.rs":"2eebab93230a59cd87c7884e95c91b3a8736c0a76814dd040864b8c25f0d5f9e","src/os/mod.rs":"6c59ef8c1120953ae6b6c32f27766c643ca90d85075c49c3545d2fe1ed82cedd","src/os/unix/consts.rs":"8d0422d6063c617e1a91425da4233f8d83de3667a011cb9e50b10736b9158c50","src/os/unix/mod.rs":"b4bdccdbd0a2f75593cf5355f54b1494a917c58fcb2e76528b8deedf481d65f2","src/os/windows/mod.rs":"c51ca318114dd4ec2e515b3e0539c11c5f1b86ad7fdbe7bc889dd929eee23b30","src/safe.rs":"b0dc1cb5c8e0216e365063b5e84218b2377bb7a62714fca9a6215a22a7bc58b8","src/test_helpers.rs":"201403e143e5b3204864124cd38067cf8813d5273dc1a9099288a9dc4bdd15b6","src/util.rs":"0b6dcfb9eafff2d87966460ef6b1b99980f888813037e787ed92deee602f8c2b","tests/constants.rs":"4778c062605ed22238c1bed16de4c076d0857282f090f36e6d985dafb7b4544d","tests/functions.rs":"57c5b15b679ccee3c0bd8e677dbecb14d1019dd82dc9207aa20b931d915ce39d","tests/library_filename.rs":"b1481f0bb374687c5f24e25113426d2a95f08a45fb8bc41a41e8702bd5a7b4bf","tests/markers.rs":"0ebc8f807b92e39452d35732988012cdca7ce96231c57eaac9c3f4217225ad39","tests/nagisa32.dll":"5c69b2bd9c8a6ad04165c221075fc9fade1dd66ca697399ace528a5a62328e36","tests/nagisa64.dll":"e20b95e3036f3289421abd100760874d4f455afd33c3b5b64fec56b191f7d477","tests/windows.rs":"35584a46658b305cd539712d3ba3c21fe7a130fd693aa1389e4886a67625d532"},"package":"efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd"} \ No newline at end of file
+{"files":{"Cargo.toml":"30f23c025249e7779afd2a52fdaba7145dd75c2a3e5a0a23f3322261d6b94c59","LICENSE":"b29f8b01452350c20dd1af16ef83b598fea3053578ccc1c7a0ef40e57be2620f","README.mkd":"973a5fa332a8f33abc73ffc0ed509f81c66dbd681d8f50969cac32cdfe16ecb2","src/changelog.rs":"a49ff30e81a245fdcef957a3fffed5a5a5b56825bc51f6ed26fe4c12f75d359c","src/error.rs":"156c53e299e8f1cd4694b277a5d92772a8a9e7ec4004bae067367f4c2502de8b","src/lib.rs":"2eebab93230a59cd87c7884e95c91b3a8736c0a76814dd040864b8c25f0d5f9e","src/os/mod.rs":"6c59ef8c1120953ae6b6c32f27766c643ca90d85075c49c3545d2fe1ed82cedd","src/os/unix/consts.rs":"1418cc26329d01ee6bc9c1144881873a66ac2183c1bf1d589904d569656c80f2","src/os/unix/mod.rs":"dff9590acbbb9a02baea9d2eb870515104c9d519b1896887f3bf1434db442929","src/os/windows/mod.rs":"b14478d7f9d4e8edc8afcbc7aa695ede1ccdd739a94242cb8dbb154fe04e4999","src/safe.rs":"b0dc1cb5c8e0216e365063b5e84218b2377bb7a62714fca9a6215a22a7bc58b8","src/test_helpers.rs":"201403e143e5b3204864124cd38067cf8813d5273dc1a9099288a9dc4bdd15b6","src/util.rs":"0b6dcfb9eafff2d87966460ef6b1b99980f888813037e787ed92deee602f8c2b","tests/constants.rs":"4778c062605ed22238c1bed16de4c076d0857282f090f36e6d985dafb7b4544d","tests/functions.rs":"0cbcc193f8aad71df626aefab9881a76f17c5a4b241855b602ce874018392db7","tests/library_filename.rs":"b1481f0bb374687c5f24e25113426d2a95f08a45fb8bc41a41e8702bd5a7b4bf","tests/markers.rs":"0ebc8f807b92e39452d35732988012cdca7ce96231c57eaac9c3f4217225ad39","tests/nagisa32.dll":"5c69b2bd9c8a6ad04165c221075fc9fade1dd66ca697399ace528a5a62328e36","tests/nagisa64.dll":"e20b95e3036f3289421abd100760874d4f455afd33c3b5b64fec56b191f7d477","tests/windows.rs":"35584a46658b305cd539712d3ba3c21fe7a130fd693aa1389e4886a67625d532"},"package":"b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"} \ No newline at end of file
diff --git a/vendor/libloading/Cargo.toml b/vendor/libloading/Cargo.toml
index 39b41f3e4..65168d585 100644
--- a/vendor/libloading/Cargo.toml
+++ b/vendor/libloading/Cargo.toml
@@ -12,25 +12,40 @@
[package]
rust-version = "1.40.0"
name = "libloading"
-version = "0.7.3"
+version = "0.7.4"
authors = ["Simonas Kazlauskas <libloading@kazlauskas.me>"]
description = "Bindings around the platform's dynamic library loading primitives with greatly improved memory safety."
documentation = "https://docs.rs/libloading/"
readme = "README.mkd"
-keywords = ["dlopen", "load", "shared", "dylib"]
+keywords = [
+ "dlopen",
+ "load",
+ "shared",
+ "dylib",
+]
categories = ["api-bindings"]
license = "ISC"
repository = "https://github.com/nagisa/rust_libloading/"
+
[package.metadata.docs.rs]
all-features = true
-rustdoc-args = ["--cfg", "libloading_docs"]
+rustdoc-args = [
+ "--cfg",
+ "libloading_docs",
+]
+
[dev-dependencies.libc]
version = "0.2"
[dev-dependencies.static_assertions]
version = "1.1"
+
[target."cfg(unix)".dependencies.cfg-if]
version = "1"
+
[target."cfg(windows)".dependencies.winapi]
version = "0.3"
-features = ["errhandlingapi", "libloaderapi"]
+features = [
+ "errhandlingapi",
+ "libloaderapi",
+]
diff --git a/vendor/libloading/src/changelog.rs b/vendor/libloading/src/changelog.rs
index f8b898e6c..162544f34 100644
--- a/vendor/libloading/src/changelog.rs
+++ b/vendor/libloading/src/changelog.rs
@@ -1,5 +1,12 @@
//! The change log.
+/// Release 0.7.4 (2022-11-07)
+///
+/// This release has no functional changes.
+///
+/// `RTLD_LAZY`, `RTLD_GLOBAL` and `RTLD_LOCAL` constants have been implemented for AIX platforms.
+pub mod r0_7_4 {}
+
/// Release 0.7.3 (2022-01-15)
///
/// This release has no functional changes.
@@ -198,7 +205,7 @@ pub mod r0_6_1 {}
/// Release 0.6.0 (2020-04-05)
///
/// * Introduced a new method [`os::unix::Library::get_singlethreaded`];
-/// * Added (untested) support for building when targetting Redox and Fuchsia;
+/// * Added (untested) support for building when targeting Redox and Fuchsia;
/// * The APIs exposed by this library no longer panic and instead return an `Err` when it used
/// to panic.
///
diff --git a/vendor/libloading/src/os/unix/consts.rs b/vendor/libloading/src/os/unix/consts.rs
index dbe4df972..ea7a6a102 100644
--- a/vendor/libloading/src/os/unix/consts.rs
+++ b/vendor/libloading/src/os/unix/consts.rs
@@ -60,6 +60,8 @@ mod posix {
cfg_if! {
if #[cfg(target_os = "haiku")] {
pub(super) const RTLD_LAZY: c_int = 0;
+ } else if #[cfg(target_os = "aix")] {
+ pub(super) const RTLD_LAZY: c_int = 4;
} else if #[cfg(any(
target_os = "linux",
target_os = "android",
@@ -104,6 +106,7 @@ mod posix {
target_os = "openbsd",
target_os = "netbsd",
+ target_os = "aix",
target_os = "solaris",
target_os = "illumos",
@@ -129,6 +132,8 @@ mod posix {
all(target_os = "android",target_pointer_width = "32"),
))] {
pub(super) const RTLD_GLOBAL: c_int = 2;
+ } else if #[cfg(target_os = "aix")] {
+ pub(super) const RTLD_GLOBAL: c_int = 0x10000;
} else if #[cfg(any(
target_env = "uclibc",
all(target_os = "linux", target_arch = "mips"),
@@ -169,6 +174,8 @@ mod posix {
cfg_if! {
if #[cfg(target_os = "netbsd")] {
pub(super) const RTLD_LOCAL: c_int = 0x200;
+ } else if #[cfg(target_os = "aix")] {
+ pub(super) const RTLD_LOCAL: c_int = 0x80000;
} else if #[cfg(any(
target_os = "macos",
target_os = "ios",
diff --git a/vendor/libloading/src/os/unix/mod.rs b/vendor/libloading/src/os/unix/mod.rs
index fd0777eab..df7efdad5 100644
--- a/vendor/libloading/src/os/unix/mod.rs
+++ b/vendor/libloading/src/os/unix/mod.rs
@@ -365,9 +365,7 @@ pub struct Symbol<T> {
impl<T> Symbol<T> {
/// Convert the loaded `Symbol` into a raw pointer.
pub fn into_raw(self) -> *mut raw::c_void {
- let pointer = self.pointer;
- mem::forget(self);
- pointer
+ self.pointer
}
}
diff --git a/vendor/libloading/src/os/windows/mod.rs b/vendor/libloading/src/os/windows/mod.rs
index eadeb6980..e3da940a2 100644
--- a/vendor/libloading/src/os/windows/mod.rs
+++ b/vendor/libloading/src/os/windows/mod.rs
@@ -307,7 +307,7 @@ impl fmt::Debug for Library {
let mut buf =
mem::MaybeUninit::<[mem::MaybeUninit::<WCHAR>; 1024]>::uninit().assume_init();
let len = libloaderapi::GetModuleFileNameW(self.0,
- (&mut buf[..]).as_mut_ptr().cast(), 1024) as usize;
+ buf[..].as_mut_ptr().cast(), 1024) as usize;
if len == 0 {
f.write_str(&format!("Library@{:p}", self.0))
} else {
@@ -333,9 +333,7 @@ pub struct Symbol<T> {
impl<T> Symbol<T> {
/// Convert the loaded `Symbol` into a handle.
pub fn into_raw(self) -> FARPROC {
- let pointer = self.pointer;
- mem::forget(self);
- pointer
+ self.pointer
}
}
diff --git a/vendor/libloading/tests/functions.rs b/vendor/libloading/tests/functions.rs
index 795f0cfe9..c8d1952b3 100644
--- a/vendor/libloading/tests/functions.rs
+++ b/vendor/libloading/tests/functions.rs
@@ -2,19 +2,26 @@
extern crate winapi;
extern crate libloading;
-use libloading::{Symbol, Library};
+use libloading::{Library, Symbol};
-const LIBPATH: &'static str = "target/libtest_helpers.module";
+const TARGET_DIR: Option<&'static str> = option_env!("CARGO_TARGET_DIR");
+const TARGET_TMPDIR: Option<&'static str> = option_env!("CARGO_TARGET_TMPDIR");
+
+fn lib_path() -> std::path::PathBuf {
+ [
+ TARGET_TMPDIR.unwrap_or(TARGET_DIR.unwrap_or("target")),
+ "libtest_helpers.module",
+ ]
+ .iter()
+ .collect()
+}
fn make_helpers() {
static ONCE: ::std::sync::Once = ::std::sync::Once::new();
ONCE.call_once(|| {
- let rustc = std::env::var_os("RUSTC").unwrap_or_else(|| { "rustc".into() });
+ let rustc = std::env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
let mut cmd = ::std::process::Command::new(rustc);
- cmd
- .arg("src/test_helpers.rs")
- .arg("-o")
- .arg(LIBPATH);
+ cmd.arg("src/test_helpers.rs").arg("-o").arg(lib_path());
if let Some(target) = std::env::var_os("TARGET") {
cmd.arg("--target").arg(target);
} else {
@@ -23,8 +30,7 @@ fn make_helpers() {
assert!(cmd
.status()
.expect("could not compile the test helpers!")
- .success()
- );
+ .success());
});
}
@@ -32,28 +38,41 @@ fn make_helpers() {
fn test_id_u32() {
make_helpers();
unsafe {
- let lib = Library::new(LIBPATH).unwrap();
- let f: Symbol<unsafe extern fn(u32) -> u32> = lib.get(b"test_identity_u32\0").unwrap();
+ let lib = Library::new(lib_path()).unwrap();
+ let f: Symbol<unsafe extern "C" fn(u32) -> u32> = lib.get(b"test_identity_u32\0").unwrap();
assert_eq!(42, f(42));
}
}
#[repr(C)]
-#[derive(Clone,Copy,PartialEq,Debug)]
+#[derive(Clone, Copy, PartialEq, Debug)]
struct S {
a: u64,
b: u32,
c: u16,
- d: u8
+ d: u8,
}
#[test]
fn test_id_struct() {
make_helpers();
unsafe {
- let lib = Library::new(LIBPATH).unwrap();
- let f: Symbol<unsafe extern fn(S) -> S> = lib.get(b"test_identity_struct\0").unwrap();
- assert_eq!(S { a: 1, b: 2, c: 3, d: 4 }, f(S { a: 1, b: 2, c: 3, d: 4 }));
+ let lib = Library::new(lib_path()).unwrap();
+ let f: Symbol<unsafe extern "C" fn(S) -> S> = lib.get(b"test_identity_struct\0").unwrap();
+ assert_eq!(
+ S {
+ a: 1,
+ b: 2,
+ c: 3,
+ d: 4
+ },
+ f(S {
+ a: 1,
+ b: 2,
+ c: 3,
+ d: 4
+ })
+ );
}
}
@@ -61,9 +80,9 @@ fn test_id_struct() {
fn test_0_no_0() {
make_helpers();
unsafe {
- let lib = Library::new(LIBPATH).unwrap();
- let f: Symbol<unsafe extern fn(S) -> S> = lib.get(b"test_identity_struct\0").unwrap();
- let f2: Symbol<unsafe extern fn(S) -> S> = lib.get(b"test_identity_struct").unwrap();
+ let lib = Library::new(lib_path()).unwrap();
+ let f: Symbol<unsafe extern "C" fn(S) -> S> = lib.get(b"test_identity_struct\0").unwrap();
+ let f2: Symbol<unsafe extern "C" fn(S) -> S> = lib.get(b"test_identity_struct").unwrap();
assert_eq!(*f, *f2);
}
}
@@ -71,7 +90,9 @@ fn test_0_no_0() {
#[test]
fn wrong_name_fails() {
unsafe {
- Library::new("target/this_location_is_definitely_non existent:^~").err().unwrap();
+ Library::new("target/this_location_is_definitely_non existent:^~")
+ .err()
+ .unwrap();
}
}
@@ -79,7 +100,7 @@ fn wrong_name_fails() {
fn missing_symbol_fails() {
make_helpers();
unsafe {
- let lib = Library::new(LIBPATH).unwrap();
+ let lib = Library::new(lib_path()).unwrap();
lib.get::<*mut ()>(b"test_does_not_exist").err().unwrap();
lib.get::<*mut ()>(b"test_does_not_exist\0").err().unwrap();
}
@@ -89,9 +110,11 @@ fn missing_symbol_fails() {
fn interior_null_fails() {
make_helpers();
unsafe {
- let lib = Library::new(LIBPATH).unwrap();
+ let lib = Library::new(lib_path()).unwrap();
lib.get::<*mut ()>(b"test_does\0_not_exist").err().unwrap();
- lib.get::<*mut ()>(b"test\0_does_not_exist\0").err().unwrap();
+ lib.get::<*mut ()>(b"test\0_does_not_exist\0")
+ .err()
+ .unwrap();
}
}
@@ -99,10 +122,10 @@ fn interior_null_fails() {
fn test_incompatible_type() {
make_helpers();
unsafe {
- let lib = Library::new(LIBPATH).unwrap();
+ let lib = Library::new(lib_path()).unwrap();
assert!(match lib.get::<()>(b"test_identity_u32\0") {
- Err(libloading::Error::IncompatibleSize) => true,
- _ => false,
+ Err(libloading::Error::IncompatibleSize) => true,
+ _ => false,
})
}
}
@@ -114,10 +137,10 @@ fn test_incompatible_type_named_fn() {
l.get::<T>(b"test_identity_u32\0")
}
unsafe {
- let lib = Library::new(LIBPATH).unwrap();
+ let lib = Library::new(lib_path()).unwrap();
assert!(match get(&lib, test_incompatible_type_named_fn) {
- Err(libloading::Error::IncompatibleSize) => true,
- _ => false,
+ Err(libloading::Error::IncompatibleSize) => true,
+ _ => false,
})
}
}
@@ -126,10 +149,11 @@ fn test_incompatible_type_named_fn() {
fn test_static_u32() {
make_helpers();
unsafe {
- let lib = Library::new(LIBPATH).unwrap();
+ let lib = Library::new(lib_path()).unwrap();
let var: Symbol<*mut u32> = lib.get(b"TEST_STATIC_U32\0").unwrap();
**var = 42;
- let help: Symbol<unsafe extern fn() -> u32> = lib.get(b"test_get_static_u32\0").unwrap();
+ let help: Symbol<unsafe extern "C" fn() -> u32> =
+ lib.get(b"test_get_static_u32\0").unwrap();
assert_eq!(42, help());
}
}
@@ -138,10 +162,10 @@ fn test_static_u32() {
fn test_static_ptr() {
make_helpers();
unsafe {
- let lib = Library::new(LIBPATH).unwrap();
+ let lib = Library::new(lib_path()).unwrap();
let var: Symbol<*mut *mut ()> = lib.get(b"TEST_STATIC_PTR\0").unwrap();
**var = *var as *mut _;
- let works: Symbol<unsafe extern fn() -> bool> =
+ let works: Symbol<unsafe extern "C" fn() -> bool> =
lib.get(b"test_check_static_ptr\0").unwrap();
assert!(works());
}
@@ -152,25 +176,26 @@ fn test_static_ptr() {
// and unloaded many times. So far it seems like an issue with mingw, not libloading, so ignoring
// the target. Especially since it is very unlikely to be fixed given the state of support its
// support.
-#[cfg(not(all(target_arch="x86", target_os="windows", target_env="gnu")))]
+#[cfg(not(all(target_arch = "x86", target_os = "windows", target_env = "gnu")))]
fn manual_close_many_times() {
make_helpers();
- let join_handles: Vec<_> = (0..16).map(|_| {
- std::thread::spawn(|| unsafe {
- for _ in 0..10000 {
- let lib = Library::new(LIBPATH).expect("open library");
- let _: Symbol<unsafe extern fn(u32) -> u32> =
- lib.get(b"test_identity_u32").expect("get fn");
- lib.close().expect("close is successful");
- }
+ let join_handles: Vec<_> = (0..16)
+ .map(|_| {
+ std::thread::spawn(|| unsafe {
+ for _ in 0..10000 {
+ let lib = Library::new(lib_path()).expect("open library");
+ let _: Symbol<unsafe extern "C" fn(u32) -> u32> =
+ lib.get(b"test_identity_u32").expect("get fn");
+ lib.close().expect("close is successful");
+ }
+ })
})
- }).collect();
+ .collect();
for handle in join_handles {
handle.join().expect("thread should succeed");
}
}
-
#[cfg(unix)]
#[test]
fn library_this_get() {
@@ -178,10 +203,12 @@ fn library_this_get() {
make_helpers();
// SAFE: functions are never called
unsafe {
- let _lib = Library::new(LIBPATH).unwrap();
+ let _lib = Library::new(lib_path()).unwrap();
let this = Library::this();
// Library we loaded in `_lib` (should be RTLD_LOCAL).
- assert!(this.get::<unsafe extern "C" fn()>(b"test_identity_u32").is_err());
+ assert!(this
+ .get::<unsafe extern "C" fn()>(b"test_identity_u32")
+ .is_err());
// Something obscure from libc...
assert!(this.get::<unsafe extern "C" fn()>(b"freopen").is_ok());
}
@@ -194,11 +221,13 @@ fn library_this() {
make_helpers();
unsafe {
// SAFE: well-known library without initialisers is loaded.
- let _lib = Library::new(LIBPATH).unwrap();
+ let _lib = Library::new(lib_path()).unwrap();
let this = Library::this().expect("this library");
// SAFE: functions are never called.
// Library we loaded in `_lib`.
- assert!(this.get::<unsafe extern "C" fn()>(b"test_identity_u32").is_err());
+ assert!(this
+ .get::<unsafe extern "C" fn()>(b"test_identity_u32")
+ .is_err());
// Something "obscure" from kernel32...
assert!(this.get::<unsafe extern "C" fn()>(b"GetLastError").is_err());
}
@@ -207,9 +236,9 @@ fn library_this() {
#[cfg(windows)]
#[test]
fn works_getlasterror() {
- use winapi::um::errhandlingapi;
- use winapi::shared::minwindef::DWORD;
use libloading::os::windows::{Library, Symbol};
+ use winapi::shared::minwindef::DWORD;
+ use winapi::um::errhandlingapi;
unsafe {
let lib = Library::new("kernel32.dll").unwrap();
@@ -222,9 +251,9 @@ fn works_getlasterror() {
#[cfg(windows)]
#[test]
fn works_getlasterror0() {
- use winapi::um::errhandlingapi;
- use winapi::shared::minwindef::DWORD;
use libloading::os::windows::{Library, Symbol};
+ use winapi::shared::minwindef::DWORD;
+ use winapi::um::errhandlingapi;
unsafe {
let lib = Library::new("kernel32.dll").unwrap();