diff -Nru rust-libloading-0.7.2/Cargo.toml rust-libloading-0.7.4/Cargo.toml --- rust-libloading-0.7.2/Cargo.toml 1970-01-01 00:00:01.000000000 +0000 +++ rust-libloading-0.7.4/Cargo.toml 1970-01-01 00:00:01.000000000 +0000 @@ -12,25 +12,40 @@ [package] rust-version = "1.40.0" name = "libloading" -version = "0.7.2" +version = "0.7.4" authors = ["Simonas Kazlauskas "] 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", "docsrs"] +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 -Nru rust-libloading-0.7.2/Cargo.toml.orig rust-libloading-0.7.4/Cargo.toml.orig --- rust-libloading-0.7.2/Cargo.toml.orig 1973-11-29 21:33:09.000000000 +0000 +++ rust-libloading-0.7.4/Cargo.toml.orig 2006-07-24 01:21:28.000000000 +0000 @@ -3,7 +3,7 @@ # When bumping # * Don’t forget to add an entry to `src/changelog.rs` # * If bumping to an incompatible version, adjust the documentation in `src/lib.rs` -version = "0.7.2" +version = "0.7.4" authors = ["Simonas Kazlauskas "] license = "ISC" repository = "https://github.com/nagisa/rust_libloading/" @@ -30,4 +30,4 @@ [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "libloading_docs"] diff -Nru rust-libloading-0.7.2/.cargo_vcs_info.json rust-libloading-0.7.4/.cargo_vcs_info.json --- rust-libloading-0.7.2/.cargo_vcs_info.json 1970-01-01 00:00:01.000000000 +0000 +++ rust-libloading-0.7.4/.cargo_vcs_info.json 1970-01-01 00:00:01.000000000 +0000 @@ -1,5 +1,6 @@ { "git": { - "sha1": "b706286d0f5627e22d15f7a8bc9be341fa26736a" - } + "sha1": "6e284984aee68cc2d1b7e7d5e7b5a2a2279cf8e3" + }, + "path_in_vcs": "" } \ No newline at end of file diff -Nru rust-libloading-0.7.2/debian/cargo-checksum.json rust-libloading-0.7.4/debian/cargo-checksum.json --- rust-libloading-0.7.2/debian/cargo-checksum.json 2021-12-19 06:00:04.000000000 +0000 +++ rust-libloading-0.7.4/debian/cargo-checksum.json 2022-12-08 01:43:56.000000000 +0000 @@ -1 +1 @@ -{"package":"Could not get crate checksum","files":{}} +{"package":"b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f","files":{}} diff -Nru rust-libloading-0.7.2/debian/changelog rust-libloading-0.7.4/debian/changelog --- rust-libloading-0.7.2/debian/changelog 2021-12-19 06:00:04.000000000 +0000 +++ rust-libloading-0.7.4/debian/changelog 2022-12-08 01:43:56.000000000 +0000 @@ -1,3 +1,11 @@ +rust-libloading (0.7.4-1) unstable; urgency=medium + + * Team upload. + * Package libloading 0.7.4 from crates.io using debcargo 2.6.0 + * Drop test-target_dir.patch, applied upstream + + -- James McCoy Wed, 07 Dec 2022 20:43:56 -0500 + rust-libloading (0.7.2-1) unstable; urgency=medium * Team upload. diff -Nru rust-libloading-0.7.2/debian/control rust-libloading-0.7.4/debian/control --- rust-libloading-0.7.2/debian/control 2021-12-19 06:00:04.000000000 +0000 +++ rust-libloading-0.7.4/debian/control 2022-12-08 01:43:56.000000000 +0000 @@ -13,7 +13,7 @@ Maintainer: Debian Rust Maintainers Uploaders: kpcyrd -Standards-Version: 4.5.1 +Standards-Version: 4.6.1 Vcs-Git: https://salsa.debian.org/rust-team/debcargo-conf.git [src/libloading] Vcs-Browser: https://salsa.debian.org/rust-team/debcargo-conf/tree/master/src/libloading X-Cargo-Crate: libloading @@ -34,8 +34,8 @@ librust-libloading-0+default-dev (= ${binary:Version}), librust-libloading-0.7-dev (= ${binary:Version}), librust-libloading-0.7+default-dev (= ${binary:Version}), - librust-libloading-0.7.2-dev (= ${binary:Version}), - librust-libloading-0.7.2+default-dev (= ${binary:Version}) + librust-libloading-0.7.4-dev (= ${binary:Version}), + librust-libloading-0.7.4+default-dev (= ${binary:Version}) Description: Safer binding to dynamic library loading utilities - Rust source code This package contains the source for the Rust libloading crate, packaged by debcargo for use with cargo and dh-cargo. diff -Nru rust-libloading-0.7.2/debian/copyright.debcargo.hint rust-libloading-0.7.4/debian/copyright.debcargo.hint --- rust-libloading-0.7.2/debian/copyright.debcargo.hint 2021-12-19 06:00:04.000000000 +0000 +++ rust-libloading-0.7.4/debian/copyright.debcargo.hint 2022-12-08 01:43:56.000000000 +0000 @@ -12,7 +12,7 @@ be correct information so you should review and fix this before uploading to the archive. -Files: ./LICENSE +Files: LICENSE Copyright: 2015, Simonas Kazlauskas License: UNKNOWN-LICENSE; FIXME (overlay) Comment: @@ -21,8 +21,8 @@ Files: debian/* Copyright: - 2018-2021 Debian Rust Maintainers - 2018-2021 kpcyrd + 2018-2022 Debian Rust Maintainers + 2018-2022 kpcyrd License: ISC License: ISC diff -Nru rust-libloading-0.7.2/debian/patches/series rust-libloading-0.7.4/debian/patches/series --- rust-libloading-0.7.2/debian/patches/series 2021-12-19 06:00:04.000000000 +0000 +++ rust-libloading-0.7.4/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -test-target_dir.patch diff -Nru rust-libloading-0.7.2/debian/patches/test-target_dir.patch rust-libloading-0.7.4/debian/patches/test-target_dir.patch --- rust-libloading-0.7.2/debian/patches/test-target_dir.patch 2021-12-19 06:00:04.000000000 +0000 +++ rust-libloading-0.7.4/debian/patches/test-target_dir.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -Index: libloading/tests/functions.rs -=================================================================== ---- libloading.orig/tests/functions.rs -+++ libloading/tests/functions.rs -@@ -4,7 +4,7 @@ extern crate winapi; - extern crate libloading; - use libloading::{Symbol, Library}; - --const LIBPATH: &'static str = "target/libtest_helpers.module"; -+const LIBPATH: &'static str = concat!(env!("CARGO_TARGET_DIR"), "/libtest_helpers.module"); - - fn make_helpers() { - static ONCE: ::std::sync::Once = ::std::sync::Once::new(); diff -Nru rust-libloading-0.7.2/debian/tests/control rust-libloading-0.7.4/debian/tests/control --- rust-libloading-0.7.2/debian/tests/control 2021-12-19 06:00:04.000000000 +0000 +++ rust-libloading-0.7.4/debian/tests/control 2022-12-08 01:43:56.000000000 +0000 @@ -1,14 +1,14 @@ -Test-Command: /usr/share/cargo/bin/cargo-auto-test libloading 0.7.2 --all-targets --all-features +Test-Command: /usr/share/cargo/bin/cargo-auto-test libloading 0.7.4 --all-targets --all-features Features: test-name=rust-libloading:@ Depends: dh-cargo (>= 18), librust-libc-0.2+default-dev, librust-static-assertions-1+default-dev (>= 1.1-~~), @ Restrictions: allow-stderr, skip-not-installable -Test-Command: /usr/share/cargo/bin/cargo-auto-test libloading 0.7.2 --all-targets +Test-Command: /usr/share/cargo/bin/cargo-auto-test libloading 0.7.4 --all-targets Features: test-name=librust-libloading-dev:default Depends: dh-cargo (>= 18), librust-libc-0.2+default-dev, librust-static-assertions-1+default-dev (>= 1.1-~~), @ Restrictions: allow-stderr, skip-not-installable -Test-Command: /usr/share/cargo/bin/cargo-auto-test libloading 0.7.2 --all-targets --no-default-features +Test-Command: /usr/share/cargo/bin/cargo-auto-test libloading 0.7.4 --all-targets --no-default-features Features: test-name=librust-libloading-dev: Depends: dh-cargo (>= 18), librust-libc-0.2+default-dev, librust-static-assertions-1+default-dev (>= 1.1-~~), @ Restrictions: allow-stderr, skip-not-installable diff -Nru rust-libloading-0.7.2/.github/workflows/libloading.yml rust-libloading-0.7.4/.github/workflows/libloading.yml --- rust-libloading-0.7.2/.github/workflows/libloading.yml 1973-11-29 21:33:09.000000000 +0000 +++ rust-libloading-0.7.4/.github/workflows/libloading.yml 2006-07-24 01:21:28.000000000 +0000 @@ -1,10 +1,11 @@ -name: Test libloading +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true on: push: - paths-ignore: - - '*.mkd' - - 'LICENSE' + branches: [master] + paths-ignore: ['*.mkd', 'LICENSE'] pull_request: types: [opened, reopened, synchronize] @@ -19,36 +20,18 @@ timeout-minutes: 20 steps: - uses: actions/checkout@v2 - - name: Install Rust ${{ matrix.rust_toolchain }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust_toolchain }} - profile: minimal - components: clippy - default: true - - name: Clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - - name: Test - uses: actions-rs/cargo@v1 - with: - command: test - args: -- --nocapture - - name: Test Release - uses: actions-rs/cargo@v1 - with: - command: test - args: --release -- --nocapture - - name: Documentation - uses: actions-rs/cargo@v1 - with: - command: doc - env: - RUSTDOCFLAGS: --cfg docsrs -Drustdoc::broken_intra_doc_links + - run: rustup install ${{ matrix.rust_toolchain }} --profile=minimal + - run: rustup default ${{ matrix.rust_toolchain }} + - run: rustup component add clippy + - run: cargo clippy + - run: cargo test -- --nocapture + - run: cargo test --release -- --nocapture + - run: cargo rustdoc -Zunstable-options --config 'build.rustdocflags=["--cfg", "libloading_docs", "-D", "rustdoc::broken_intra_doc_links"]' if: ${{ matrix.rust_toolchain == 'nightly' }} + # pwsh.exe drops quotes kekw. https://stackoverflow.com/a/59036879 + shell: bash - windows-gnu-test: + windows-test: runs-on: windows-latest strategy: fail-fast: false @@ -57,39 +40,35 @@ rust_target: - x86_64-pc-windows-gnu - i686-pc-windows-gnu + include: + - rust_target: x86_64-pc-windows-gnu + mingw_path: C:/msys64/mingw64/bin + package: mingw-w64-x86_64-gcc + - rust_target: i686-pc-windows-gnu + mingw_path: C:/msys64/mingw32/bin + package: mingw-w64-i686-gcc steps: - uses: actions/checkout@v2 - - name: Add MSYS2 to the PATH - run: echo "c:/msys64/bin" | Out-File -FilePath $env:GITHUB_PATH -Append - - name: Add 32-bit mingw-w64 to the PATH - run: echo "c:/msys64/mingw32/bin" | Out-File -FilePath $env:GITHUB_PATH -Append - if: startsWith(matrix.rust_target, 'i686') - - name: Add 64-bit mingw-w64 to the PATH - run: echo "c:/msys64/mingw64/bin" | Out-File -FilePath $env:GITHUB_PATH -Append - if: startsWith(matrix.rust_target, 'x86_64') - - name: Set TARGET variable - run: echo "TARGET=${{ matrix.rust_target}}" | Out-File -FilePath $env:GITHUB_ENV -Append - - name: Install Rust nightly - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust_toolchain }} - target: ${{ matrix.rust_target }} - profile: minimal - default: true - - uses: actions-rs/cargo@v1 - with: - command: build - args: --target ${{ matrix.rust_target }} --manifest-path=Cargo.toml - - uses: actions-rs/cargo@v1 - with: - command: test - args: --target ${{ matrix.rust_target }} --manifest-path=Cargo.toml + - run: rustup install ${{ matrix.rust_toolchain }} --profile=minimal + - run: rustup default ${{ matrix.rust_toolchain }} + - run: rustup target add ${{ matrix.rust_target }} + - uses: msys2/setup-msys2@v2 + with: + release: false + install: ${{ matrix.package }} + - run: echo "c:/msys64/bin" | Out-File -FilePath $env:GITHUB_PATH -Append + - run: echo "${{ matrix.mingw_path }}" | Out-File -FilePath $env:GITHUB_PATH -Append + if: ${{ matrix.mingw_path }}" + - run: cargo test --target ${{ matrix.rust_target }} + env: + TARGET: ${{ matrix.rust_target}} bare-cross-build: runs-on: ubuntu-latest strategy: fail-fast: false matrix: + rust_toolchain: [nightly] rust_target: # BSDs: could be tested with full system emulation # - x86_64-unknown-dragonfly @@ -103,25 +82,10 @@ timeout-minutes: 20 steps: - uses: actions/checkout@v2 - - name: Install Rust nightly - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - profile: minimal - default: true - - name: Fix-up toolchain - run: | - rustup component add rust-src --toolchain nightly --target ${{ matrix.rust_target }} - - name: Update - uses: actions-rs/cargo@v1 - with: - command: update - args: --manifest-path=Cargo.toml - - name: Build ${{ matrix.rust_target }} - uses: actions-rs/cargo@v1 - with: - command: build - args: --target ${{ matrix.rust_target }} --manifest-path=Cargo.toml -Zbuild-std + - run: rustup install ${{ matrix.rust_toolchain }} --profile=minimal + - run: rustup default ${{ matrix.rust_toolchain }} + - run: rustup component add rust-src --toolchain nightly --target ${{ matrix.rust_target }} + - run: cargo build --target ${{ matrix.rust_target }} -Zbuild-std cross-ios-build: runs-on: macos-latest @@ -135,20 +99,7 @@ timeout-minutes: 20 steps: - uses: actions/checkout@v2 - - name: Install Rust ${{ matrix.rust_toolchain }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust_toolchain }} - target: ${{ matrix.rust_target }} - profile: minimal - default: true - - name: Update - uses: actions-rs/cargo@v1 - with: - command: update - args: --manifest-path=Cargo.toml - - name: Build ${{ matrix.rust_target }} - uses: actions-rs/cargo@v1 - with: - command: build - args: --target=${{ matrix.rust_target }} --manifest-path=Cargo.toml + - run: rustup install ${{ matrix.rust_toolchain }} --profile=minimal + - run: rustup default ${{ matrix.rust_toolchain }} + - run: rustup target add ${{ matrix.rust_target }} + - run: cargo build --target=${{ matrix.rust_target }} diff -Nru rust-libloading-0.7.2/src/changelog.rs rust-libloading-0.7.4/src/changelog.rs --- rust-libloading-0.7.2/src/changelog.rs 1973-11-29 21:33:09.000000000 +0000 +++ rust-libloading-0.7.4/src/changelog.rs 2006-07-24 01:21:28.000000000 +0000 @@ -1,5 +1,22 @@ //! 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. +/// +/// In this release the `docsrs` `cfg` has been renamed to `libloading_docs` to better reflect that +/// this `cfg` is intended to be only used by `libloading` and only specifically for the invocation +/// of `rustdoc` when documenting `libloading`. Setting this `cfg` in any other situation is +/// unsupported and will not work. +pub mod r0_7_3 {} + /// Release 0.7.2 (2021-11-14) /// /// Cargo.toml now specifies the MSRV bounds, which enables tooling to report an early failure when @@ -188,7 +205,7 @@ /// 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 -Nru rust-libloading-0.7.2/src/lib.rs rust-libloading-0.7.4/src/lib.rs --- rust-libloading-0.7.2/src/lib.rs 1973-11-29 21:33:09.000000000 +0000 +++ rust-libloading-0.7.4/src/lib.rs 2006-07-24 01:21:28.000000000 +0000 @@ -36,7 +36,7 @@ //! The compiler will ensure that the loaded function will not outlive the `Library` from which it comes, //! preventing the most common memory-safety issues. #![cfg_attr(any(unix, windows), deny(missing_docs, clippy::all, unreachable_pub, unused))] -#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(libloading_docs, feature(doc_cfg))] pub mod changelog; pub mod os; @@ -45,9 +45,9 @@ mod error; pub use self::error::Error; -#[cfg(any(unix, windows, docsrs))] +#[cfg(any(unix, windows, libloading_docs))] mod safe; -#[cfg(any(unix, windows, docsrs))] +#[cfg(any(unix, windows, libloading_docs))] pub use self::safe::{Library, Symbol}; use std::env::consts::{DLL_PREFIX, DLL_SUFFIX}; diff -Nru rust-libloading-0.7.2/src/os/mod.rs rust-libloading-0.7.4/src/os/mod.rs --- rust-libloading-0.7.2/src/os/mod.rs 1973-11-29 21:33:09.000000000 +0000 +++ rust-libloading-0.7.4/src/os/mod.rs 2006-07-24 01:21:28.000000000 +0000 @@ -17,11 +17,11 @@ //! ``` /// UNIX implementation of dynamic library loading. -#[cfg(any(unix, docsrs))] -#[cfg_attr(docsrs, doc(cfg(unix)))] +#[cfg(any(unix, libloading_docs))] +#[cfg_attr(libloading_docs, doc(cfg(unix)))] pub mod unix; /// Windows implementation of dynamic library loading. -#[cfg(any(windows, docsrs))] -#[cfg_attr(docsrs, doc(cfg(windows)))] +#[cfg(any(windows, libloading_docs))] +#[cfg_attr(libloading_docs, doc(cfg(windows)))] pub mod windows; diff -Nru rust-libloading-0.7.2/src/os/unix/consts.rs rust-libloading-0.7.4/src/os/unix/consts.rs --- rust-libloading-0.7.2/src/os/unix/consts.rs 1973-11-29 21:33:09.000000000 +0000 +++ rust-libloading-0.7.4/src/os/unix/consts.rs 2006-07-24 01:21:28.000000000 +0000 @@ -43,7 +43,7 @@ /// any other executable object file. This mode of operation is most appropriate for e.g. plugins. pub const RTLD_LOCAL: c_int = posix::RTLD_LOCAL; -#[cfg(all(docsrs, not(unix)))] +#[cfg(all(libloading_docs, not(unix)))] mod posix { use super::c_int; pub(super) const RTLD_LAZY: c_int = !0; @@ -52,7 +52,7 @@ pub(super) const RTLD_LOCAL: c_int = !0; } -#[cfg(any(not(docsrs), unix))] +#[cfg(any(not(libloading_docs), unix))] mod posix { extern crate cfg_if; use self::cfg_if::cfg_if; @@ -60,6 +60,8 @@ 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 @@ target_os = "openbsd", target_os = "netbsd", + target_os = "aix", target_os = "solaris", target_os = "illumos", @@ -129,6 +132,8 @@ 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 @@ 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 -Nru rust-libloading-0.7.2/src/os/unix/mod.rs rust-libloading-0.7.4/src/os/unix/mod.rs --- rust-libloading-0.7.2/src/os/unix/mod.rs 1973-11-29 21:33:09.000000000 +0000 +++ rust-libloading-0.7.4/src/os/unix/mod.rs 2006-07-24 01:21:28.000000000 +0000 @@ -1,8 +1,8 @@ // A hack for docs.rs to build documentation that has both windows and linux documentation in the // same rustdoc build visible. -#[cfg(all(docsrs, not(unix)))] +#[cfg(all(libloading_docs, not(unix)))] mod unix_imports {} -#[cfg(any(not(docsrs), unix))] +#[cfg(any(not(libloading_docs), unix))] mod unix_imports { pub(super) use std::os::unix::ffi::OsStrExt; } @@ -365,9 +365,7 @@ impl Symbol { /// 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 -Nru rust-libloading-0.7.2/src/os/windows/mod.rs rust-libloading-0.7.4/src/os/windows/mod.rs --- rust-libloading-0.7.2/src/os/windows/mod.rs 1973-11-29 21:33:09.000000000 +0000 +++ rust-libloading-0.7.4/src/os/windows/mod.rs 2006-07-24 01:21:28.000000000 +0000 @@ -1,6 +1,6 @@ // A hack for docs.rs to build documentation that has both windows and linux documentation in the // same rustdoc build visible. -#[cfg(all(docsrs, not(windows)))] +#[cfg(all(libloading_docs, not(windows)))] mod windows_imports { pub(super) enum WORD {} pub(super) struct DWORD; @@ -23,7 +23,7 @@ pub(crate) const LOAD_LIBRARY_SAFE_CURRENT_DIRS: DWORD = DWORD; } } -#[cfg(any(not(docsrs), windows))] +#[cfg(any(not(libloading_docs), windows))] mod windows_imports { extern crate winapi; pub(super) use self::winapi::shared::minwindef::{WORD, DWORD, HMODULE, FARPROC}; @@ -307,7 +307,7 @@ let mut buf = mem::MaybeUninit::<[mem::MaybeUninit::; 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 @@ impl Symbol { /// Convert the loaded `Symbol` into a handle. pub fn into_raw(self) -> FARPROC { - let pointer = self.pointer; - mem::forget(self); - pointer + self.pointer } } diff -Nru rust-libloading-0.7.2/src/safe.rs rust-libloading-0.7.4/src/safe.rs --- rust-libloading-0.7.2/src/safe.rs 1973-11-29 21:33:09.000000000 +0000 +++ rust-libloading-0.7.4/src/safe.rs 2006-07-24 01:21:28.000000000 +0000 @@ -1,9 +1,9 @@ use super::Error; -#[cfg(docsrs)] +#[cfg(libloading_docs)] use super::os::unix as imp; // the implementation used here doesn't matter particularly much... -#[cfg(all(not(docsrs), unix))] +#[cfg(all(not(libloading_docs), unix))] use super::os::unix as imp; -#[cfg(all(not(docsrs), windows))] +#[cfg(all(not(libloading_docs), windows))] use super::os::windows as imp; use std::ffi::OsStr; use std::fmt; @@ -11,7 +11,7 @@ use std::ops; /// A loaded dynamic library. -#[cfg_attr(docsrs, doc(cfg(any(unix, windows))))] +#[cfg_attr(libloading_docs, doc(cfg(any(unix, windows))))] pub struct Library(imp::Library); impl Library { @@ -193,7 +193,7 @@ /// itself, without taking care to “extract” the function or variable manually most of the time. /// /// [`Library::get`]: Library::get -#[cfg_attr(docsrs, doc(cfg(any(unix, windows))))] +#[cfg_attr(libloading_docs, doc(cfg(any(unix, windows))))] pub struct Symbol<'lib, T: 'lib> { inner: imp::Symbol, pd: marker::PhantomData<&'lib T>, diff -Nru rust-libloading-0.7.2/tests/functions.rs rust-libloading-0.7.4/tests/functions.rs --- rust-libloading-0.7.2/tests/functions.rs 1973-11-29 21:33:09.000000000 +0000 +++ rust-libloading-0.7.4/tests/functions.rs 2006-07-24 01:21:28.000000000 +0000 @@ -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 @@ assert!(cmd .status() .expect("could not compile the test helpers!") - .success() - ); + .success()); }); } @@ -32,28 +38,41 @@ fn test_id_u32() { make_helpers(); unsafe { - let lib = Library::new(LIBPATH).unwrap(); - let f: Symbol u32> = lib.get(b"test_identity_u32\0").unwrap(); + let lib = Library::new(lib_path()).unwrap(); + let f: Symbol 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 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 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_0_no_0() { make_helpers(); unsafe { - let lib = Library::new(LIBPATH).unwrap(); - let f: Symbol S> = lib.get(b"test_identity_struct\0").unwrap(); - let f2: Symbol S> = lib.get(b"test_identity_struct").unwrap(); + let lib = Library::new(lib_path()).unwrap(); + let f: Symbol S> = lib.get(b"test_identity_struct\0").unwrap(); + let f2: Symbol S> = lib.get(b"test_identity_struct").unwrap(); assert_eq!(*f, *f2); } } @@ -71,7 +90,9 @@ #[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 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 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 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 @@ l.get::(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_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 u32> = lib.get(b"test_get_static_u32\0").unwrap(); + let help: Symbol u32> = + lib.get(b"test_get_static_u32\0").unwrap(); assert_eq!(42, help()); } } @@ -138,10 +162,10 @@ 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 bool> = + let works: Symbol bool> = lib.get(b"test_check_static_ptr\0").unwrap(); assert!(works()); } @@ -152,25 +176,26 @@ // 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 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 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 @@ 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::(b"test_identity_u32").is_err()); + assert!(this + .get::(b"test_identity_u32") + .is_err()); // Something obscure from libc... assert!(this.get::(b"freopen").is_ok()); } @@ -194,11 +221,13 @@ 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::(b"test_identity_u32").is_err()); + assert!(this + .get::(b"test_identity_u32") + .is_err()); // Something "obscure" from kernel32... assert!(this.get::(b"GetLastError").is_err()); } @@ -207,9 +236,9 @@ #[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 @@ #[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();