Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
# image: ubuntu:20.10
strategy:
matrix:
os: [ubuntu-24.04, macos-latest]
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-latest]
rust:
- stable
steps:
Expand All @@ -32,7 +32,7 @@ jobs:
- uses: Swatinem/rust-cache@v2.8.2
- uses: taiki-e/install-action@cargo-hack
- run: sudo apt-get update -y
if: matrix.os == 'ubuntu-24.04'
if: (matrix.os == 'ubuntu-24.04') || (matrix.os == 'ubuntu-24.04-arm')
- name: update toolchain
run: rustup toolchain install
- name: cargo check (powerset)
Expand Down
3 changes: 2 additions & 1 deletion src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,14 @@ pub use crate::sys::MetadataError;
#[cfg(test)]
mod tests {
use super::*;
use std::ffi::c_char;

#[test]
fn test_vec8_cast_to_c_string() {
let v: Vec<u8> = vec![0, 1, b'\0', 2, 3];
let c = v.as_ptr() as *const libc::c_char;
for (i, vi) in v.iter().enumerate() {
assert_eq!(*vi as i8, unsafe { *c.add(i) });
assert_eq!(*vi as c_char, unsafe { *c.add(i) });
}

let _ = match Some(&v) {
Expand Down
3 changes: 2 additions & 1 deletion src/sys/edge_table.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::ffi::c_char;
use std::ptr::NonNull;

use super::newtypes::EdgeId;
Expand Down Expand Up @@ -64,7 +65,7 @@ impl EdgeTable {
right,
parent,
child,
metadata.as_ptr().cast::<i8>(),
metadata.as_ptr().cast::<c_char>(),
metadata.len() as u64,
))
}
Expand Down
3 changes: 2 additions & 1 deletion src/sys/individual_table.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::ffi::c_char;
use std::ptr::NonNull;

use super::bindings::tsk_size_t;
Expand Down Expand Up @@ -65,7 +66,7 @@ impl IndividualTable {
location.len() as u64,
parents.as_ptr(),
parents.len() as u64,
metadata.as_ptr().cast::<i8>(),
metadata.as_ptr().cast::<c_char>(),
metadata.len() as u64,
))
}
Expand Down
3 changes: 2 additions & 1 deletion src/sys/migration_table.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::ffi::c_char;
use std::ptr::NonNull;

use super::newtypes::MigrationId;
Expand Down Expand Up @@ -71,7 +72,7 @@ impl MigrationTable {
source,
dest,
time,
metadata.as_ptr().cast::<i8>(),
metadata.as_ptr().cast::<c_char>(),
metadata.len() as u64,
))
}
Expand Down
5 changes: 3 additions & 2 deletions src/sys/mutation_table.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::ffi::c_char;
use std::ptr::NonNull;

use super::newtypes::MutationId;
Expand Down Expand Up @@ -70,14 +71,14 @@ impl MutationTable {
parent,
time,
match derived_state {
Some(d) => d.as_ptr() as *const i8,
Some(d) => d.as_ptr() as *const c_char,
None => std::ptr::null(),
},
match derived_state {
Some(d) => d.len() as u64,
None => 0,
},
metadata.as_ptr().cast::<i8>(),
metadata.as_ptr().cast::<c_char>(),
metadata.len() as u64,
))
}
Expand Down
3 changes: 2 additions & 1 deletion src/sys/node_table.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::ffi::c_char;
use std::ptr::NonNull;

use super::flags::NodeFlags;
Expand Down Expand Up @@ -80,7 +81,7 @@ impl NodeTable {
time.into().into(),
population.into().into(),
individual.into().into(),
metadata.as_ptr().cast::<i8>(),
metadata.as_ptr().cast::<c_char>(),
metadata.len() as u64,
)
} {
Expand Down
3 changes: 2 additions & 1 deletion src/sys/population_table.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::ffi::c_char;
use std::ptr::NonNull;

use super::bindings::tsk_id_t;
Expand Down Expand Up @@ -44,7 +45,7 @@ impl PopulationTable {
unsafe {
Ok(tsk_population_table_add_row(
self.as_mut(),
metadata.as_ptr().cast::<i8>(),
metadata.as_ptr().cast::<c_char>(),
metadata.len() as u64,
))
}
Expand Down
5 changes: 3 additions & 2 deletions src/sys/provenance_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use super::bindings::tsk_provenance_table_t;
use super::bindings::tsk_size_t;
use super::tskbox::TskBox;
use super::TskitError;
use std::ffi::c_char;

#[derive(Debug)]
pub struct ProvenanceTable(TskBox<tsk_provenance_table_t>);
Expand Down Expand Up @@ -49,9 +50,9 @@ impl ProvenanceTable {
let rv = unsafe {
tsk_provenance_table_add_row(
self.as_mut(),
timestamp.as_ptr() as *mut i8,
timestamp.as_ptr() as *const c_char,
timestamp.len() as tsk_size_t,
record.as_ptr() as *mut i8,
record.as_ptr() as *const c_char,
record.len() as tsk_size_t,
)
};
Expand Down
5 changes: 3 additions & 2 deletions src/sys/site_table.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::ffi::c_char;
use std::ptr::NonNull;

use super::bindings::tsk_size_t;
Expand Down Expand Up @@ -58,14 +59,14 @@ impl SiteTable {
self.as_mut(),
position,
match ancestral_state {
Some(d) => d.as_ptr() as *const i8,
Some(d) => d.as_ptr() as *const c_char,
None => std::ptr::null(),
},
match ancestral_state {
Some(d) => d.len() as u64,
None => 0,
},
metadata.as_ptr().cast::<i8>(),
metadata.as_ptr().cast::<c_char>(),
metadata.len() as u64,
))
}
Expand Down
7 changes: 5 additions & 2 deletions src/trees/treeseq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ use crate::TreeSequenceFlags;
use crate::TskReturnValue;
use sys::bindings as ll_bindings;

#[cfg(feature = "provenance")]
use std::ffi::c_char;

use super::Tree;

/// A tree sequence.
Expand Down Expand Up @@ -468,9 +471,9 @@ impl TreeSequence {
let rv = unsafe {
ll_bindings::tsk_provenance_table_add_row(
&mut (*self.inner.as_ref().tables).provenances,
timestamp.as_ptr() as *mut i8,
timestamp.as_ptr() as *const c_char,
timestamp.len() as ll_bindings::tsk_size_t,
record.as_ptr() as *mut i8,
record.as_ptr() as *const c_char,
record.len() as ll_bindings::tsk_size_t,
)
};
Expand Down
Loading