Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

Commit

Permalink
Merge pull request #163 from djs55/cstruct-stubs
Browse files Browse the repository at this point in the history
Update cstruct_stubs.c from 2.0.0
  • Loading branch information
talex5 committed May 1, 2016
2 parents 9ba2835 + 019be15 commit 1b28878
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bindings/cstruct_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <stdint.h>

#include <caml/mlvalues.h>
#include <caml/memory.h>
Expand Down Expand Up @@ -69,3 +70,11 @@ caml_fill_bigstring(value val_buf, value val_ofs, value val_len, value val_byte)
Long_val(val_len));
return Val_unit;
}

CAMLprim value
caml_check_alignment_bigstring(value val_buf, value val_ofs, value val_alignment)
{
uint64_t address = (uint64_t) (Caml_ba_data_val(val_buf) + Long_val(val_ofs));
int alignment = Int_val(val_alignment);
return Val_bool(address % alignment == 0);
}

0 comments on commit 1b28878

Please sign in to comment.