Skip to content

Commit

Permalink
Merge pull request #53 from tizoc/fix-bytecode-functions
Browse files Browse the repository at this point in the history
Fix argument types in expansion of bytecode-callable functions
  • Loading branch information
tizoc authored Aug 27, 2023
2 parents 1980c8b + 825695f commit f0e25c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Expansion of bytecode-callable functions (PR #53, reported and debugged by @mt-caret in #52).

## [0.9.1] - 2023-07-12

### Fixed
Expand Down
7 changes: 4 additions & 3 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1540,13 +1540,14 @@ macro_rules! expand_exported_byte_function {
@return { $($rtyp:tt)* }
} => {
#[no_mangle]
pub extern "C" fn $byte_name(argv: &[$crate::RawOCaml], argn: isize) -> $crate::expand_exported_function_return!($($rtyp)*) {
pub extern "C" fn $byte_name(argv: *mut $crate::RawOCaml, argn: std::os::raw::c_int) -> $crate::expand_exported_function_return!($($rtyp)*) {
let mut i = 0usize;
$(
let $arg = argv[i];
#[allow(clippy::not_unsafe_ptr_arg_deref)]
let $arg = unsafe { core::ptr::read(argv.add(i)) };
i += 1;
)+
debug_assert!(i == argn as usize);
debug_assert_eq!(i, argn as usize, "count of arguments read from argv matches argn");
$name($($arg),*)
}
};
Expand Down

0 comments on commit f0e25c7

Please sign in to comment.