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

Compiler: fix 32bit build #1699

Merged
merged 1 commit into from
Sep 30, 2024
Merged
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
11 changes: 4 additions & 7 deletions compiler/lib/targetint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ let max_int_ (Offset offset) = Int32.shift_right Int32.max_int offset

let min_int_ (Offset offset) = Int32.shift_right Int32.min_int offset

let min_int_i offset = Int32.to_int (min_int_ offset)

let max_int_i offset = Int32.to_int (max_int_ offset)

let min_int () =
let offset = offset () in
min_int_ offset
Expand All @@ -50,7 +46,7 @@ let to_float x = Int32.to_float x
let to_int32 x = x

let to_int_exn x =
if Sys.int_size <= 32 || Int32.of_int Int.min_int <= x || x <= Int32.of_int Int.max_int
if Sys.int_size >= 32 || Int32.of_int Int.min_int <= x || x <= Int32.of_int Int.max_int
then Int32.to_int x
else failwith "to_int_exn"

Expand Down Expand Up @@ -102,9 +98,10 @@ let is_zero x = equal x 0l

let of_int_exn (x : int) =
let offset = offset () in
if min_int_i offset <= x && x <= max_int_i offset
if Sys.int_size <= 32
|| (Int32.to_int (min_int_ offset) <= x && x <= Int32.to_int (max_int_ offset))
then Int32.of_int x
else failwith "of_int_exn"
else failwith (Printf.sprintf "of_int_exn(%d)" x)

let of_int32_exn (x : int32) =
let offset = offset () in
Expand Down
Loading