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

unbox the mix30 C stub #3

Merged
merged 1 commit into from
Sep 13, 2021
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
3 changes: 2 additions & 1 deletion PRNG.ml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ external mix64: int64 -> int64 = "pringo_mix64" "pringo_mix64_unboxed"
[@@unboxed] [@@noalloc]
external mix32: int64 -> int32 = "pringo_mix32" "pringo_mix32_unboxed"
[@@unboxed] [@@noalloc]
external mix30: int64 -> int = "pringo_mix30"
external mix30: (int64[@unboxed]) -> int = "pringo_mix30" "pringo_mix30_unboxed"
[@@noalloc]
external mixGamma: int64 -> int64 = "pringo_mixGamma" "pringo_mixGamma_unboxed"
[@@unboxed] [@@noalloc]

Expand Down
6 changes: 3 additions & 3 deletions stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ CAMLprim value pringo_mix32(value vz)
return caml_copy_int32(pringo_mix32_unboxed(Int64_val(vz)));
}

static inline intnat pringo_mix30_unboxed(uint64_t z)
CAMLprim value pringo_mix30_unboxed(uint64_t z)
{
z = (z ^ (z >> 33)) * 0xff51afd7ed558ccdULL;
z = (z ^ (z >> 33)) * 0xc4ceb9fe1a85ec53ULL;
return (intnat)(z >> 34);
return Val_long((intnat)(z >> 34));
}

CAMLprim value pringo_mix30(value vz)
{
return Val_long(pringo_mix30_unboxed(Int64_val(vz)));
return pringo_mix30_unboxed(Int64_val(vz));
}

static inline uint64_t mix64variant13(uint64_t z)
Expand Down