diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e00aa759..70edb361 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -65,24 +65,26 @@ jobs: matrix: target: - i686-unknown-linux-gnu + - i686-unknown-linux-musl - x86_64-unknown-linux-gnu + - x86_64-unknown-linux-musl steps: - name: Checkout uses: actions/checkout@v3 - name: Install toolchain - uses: dtolnay/rust-toolchain@master + uses: dtolnay/rust-toolchain@stable with: - toolchain: stable-${{ matrix.target }} + target: ${{ matrix.target }} - name: Install multilib - if: ${{ matrix.target == 'i686-unknown-linux-gnu' }} + if: ${{ contains(matrix.target, 'i686-unknown-linux-') }} run: | sudo apt update -yqq sudo apt install gcc-multilib - name: Run tests - run: cargo test --all-features + run: cargo test --all-features --target ${{ matrix.target }} check-stub: runs-on: ubuntu-latest diff --git a/src/unix.rs b/src/unix.rs index 6e3fd4e8..faa3b36d 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -28,6 +28,18 @@ const MAP_POPULATE: libc::c_int = libc::MAP_POPULATE; #[cfg(not(any(target_os = "linux", target_os = "android")))] const MAP_POPULATE: libc::c_int = 0; +#[cfg(any( + target_os = "android", + all(target_os = "linux", not(target_env = "musl")) +))] +use libc::{mmap64 as mmap, off64_t as off_t}; + +#[cfg(not(any( + target_os = "android", + all(target_os = "linux", not(target_env = "musl")) +)))] +use libc::{mmap, off_t}; + pub struct MmapInner { ptr: *mut libc::c_void, len: usize, @@ -50,13 +62,13 @@ impl MmapInner { let (map_len, map_offset) = Self::adjust_mmap_params(len as usize, alignment as usize)?; unsafe { - let ptr = libc::mmap( + let ptr = mmap( ptr::null_mut(), map_len as libc::size_t, prot, flags, file, - aligned_offset as libc::off_t, + aligned_offset as off_t, ); if ptr == libc::MAP_FAILED {