Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run builds on both Mac OS and Linux #830

Merged
merged 3 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ jobs:
uses: dprint/check@v2.2

cargo:
runs-on: ubuntu-latest
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
13 changes: 12 additions & 1 deletion src/exercises/day-3/safe-ffi-wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod ffi {
}

// Layout as per man entry for dirent
#[cfg(target_os = "macos")]
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
#[repr(C)]
pub struct dirent {
pub d_ino: u64,
Expand All @@ -48,6 +48,17 @@ mod ffi {
pub d_name: [c_char; 1024],
}

// Layout according to <https://github.com/rust-lang/libc/issues/414>
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
#[repr(C)]
pub struct dirent {
pub d_fileno: u32,
pub d_reclen: u16,
pub d_type: u8,
pub d_namlen: u8,
pub d_name: [c_char; 256],
}

extern "C" {
pub fn opendir(s: *const c_char) -> *mut DIR;
pub fn readdir(s: *mut DIR) -> *const dirent;
Expand Down