diff --git a/ocaml-stdint-lognot.patch b/ocaml-stdint-lognot.patch new file mode 100644 index 0000000..fdef7f9 --- /dev/null +++ b/ocaml-stdint-lognot.patch @@ -0,0 +1,135 @@ +diff --git a/lib/int40_stubs.c b/lib/int40_stubs.c +index 6a374fe..7f36caa 100644 +--- a/lib/int40_stubs.c ++++ b/lib/int40_stubs.c +@@ -29,6 +29,13 @@ int40_div(value v1, value v2) + CAMLreturn (copy_int40((Int64_val(v1) / divisor) << 24)); + } + ++CAMLprim value ++int40_xor(value v1, value v2) ++{ ++ CAMLparam2(v1, v2); ++ CAMLreturn (copy_int40((Int64_val(v1) ^ Int64_val(v2)) & mask)); ++} ++ + CAMLprim value + int40_shift_right(value v1, value v2) + { +diff --git a/lib/int48_stubs.c b/lib/int48_stubs.c +index 3173e3b..20f7141 100644 +--- a/lib/int48_stubs.c ++++ b/lib/int48_stubs.c +@@ -29,6 +29,13 @@ int48_div(value v1, value v2) + CAMLreturn (copy_int48((Int64_val(v1) / divisor) << 16)); + } + ++CAMLprim value ++int48_xor(value v1, value v2) ++{ ++ CAMLparam2(v1, v2); ++ CAMLreturn (copy_int48((Int64_val(v1) ^ Int64_val(v2)) & mask)); ++} ++ + CAMLprim value + int48_shift_right(value v1, value v2) + { +diff --git a/lib/int56_stubs.c b/lib/int56_stubs.c +index 49e6e81..690cb6a 100644 +--- a/lib/int56_stubs.c ++++ b/lib/int56_stubs.c +@@ -29,6 +29,13 @@ int56_div(value v1, value v2) + CAMLreturn (copy_int56((Int64_val(v1) / divisor) << 8)); + } + ++CAMLprim value ++int56_xor(value v1, value v2) ++{ ++ CAMLparam2(v1, v2); ++ CAMLreturn (copy_int56((Int64_val(v1) ^ Int64_val(v2)) & mask)); ++} ++ + CAMLprim value + int56_shift_right(value v1, value v2) + { +diff --git a/lib/stdint.ml b/lib/stdint.ml +index b53d3d2..b89c83d 100644 +--- a/lib/stdint.ml ++++ b/lib/stdint.ml +@@ -434,7 +434,7 @@ module Int40 = struct + + external mul : int40 -> int40 -> int40 = "int40_mul" + external div : int40 -> int40 -> int40 = "int40_div" +- external logxor : int40 -> int40 -> int40 = "uint40_xor" ++ external logxor : int40 -> int40 -> int40 = "int40_xor" + external shift_right : int40 -> int -> int40 = "int40_shift_right" + external shift_right_logical : int40 -> int -> int40 = "uint40_shift_right" + +@@ -485,9 +485,10 @@ module Int40 = struct + external max_int_fun : unit -> int40 = "int40_max_int" + external min_int_fun : unit -> int40 = "int40_min_int" + let one = of_int 1 ++ let minus_one = of_int (-1) + let max_int = max_int_fun () + let min_int = min_int_fun () +- let lognot = logxor max_int ++ let lognot = logxor minus_one + let compare = Stdint_stdlib_.compare + let divmod = (fun x y -> div x y, rem x y) + end +@@ -518,7 +519,7 @@ module Int48 = struct + + external mul : int48 -> int48 -> int48 = "int48_mul" + external div : int48 -> int48 -> int48 = "int48_div" +- external logxor : int48 -> int48 -> int48 = "uint48_xor" ++ external logxor : int48 -> int48 -> int48 = "int48_xor" + external shift_right : int48 -> int -> int48 = "int48_shift_right" + external shift_right_logical : int48 -> int -> int48 = "uint48_shift_right" + +@@ -569,9 +570,10 @@ module Int48 = struct + external max_int_fun : unit -> int48 = "int48_max_int" + external min_int_fun : unit -> int48 = "int48_min_int" + let one = of_int 1 ++ let minus_one = of_int (-1) + let max_int = max_int_fun () + let min_int = min_int_fun () +- let lognot = logxor max_int ++ let lognot = logxor minus_one + let compare = Stdint_stdlib_.compare + let divmod = (fun x y -> div x y, rem x y) + end +@@ -602,7 +604,7 @@ module Int56 = struct + + external mul : int56 -> int56 -> int56 = "int56_mul" + external div : int56 -> int56 -> int56 = "int56_div" +- external logxor : int56 -> int56 -> int56 = "uint56_xor" ++ external logxor : int56 -> int56 -> int56 = "int56_xor" + external shift_right : int56 -> int -> int56 = "int56_shift_right" + external shift_right_logical : int56 -> int -> int56 = "uint56_shift_right" + +@@ -653,9 +655,10 @@ module Int56 = struct + external max_int_fun : unit -> int56 = "int56_max_int" + external min_int_fun : unit -> int56 = "int56_min_int" + let one = of_int 1 ++ let minus_one = of_int (-1) + let max_int = max_int_fun () + let min_int = min_int_fun () +- let lognot = logxor max_int ++ let lognot = logxor minus_one + let compare = Stdint_stdlib_.compare + let divmod = (fun x y -> div x y, rem x y) + end +@@ -742,11 +745,12 @@ module Int128 = struct + + let zero = of_int 0 + let one = of_int 1 ++ let minus_one = of_int (-1) + let succ = add one + let pred x = sub x one + let max_int = max_int_fun () + let min_int = min_int_fun () +- let lognot = logxor max_int ++ let lognot = logxor minus_one + let compare = Stdint_stdlib_.compare + let divmod = (fun x y -> div x y, rem x y) + diff --git a/ocaml-stdint-test.patch b/ocaml-stdint-test.patch new file mode 100644 index 0000000..a92416c --- /dev/null +++ b/ocaml-stdint-test.patch @@ -0,0 +1,37 @@ +--- a/tests/stdint_test.ml ++++ b/tests/stdint_test.ml +@@ -22,7 +22,8 @@ struct + let () = assert (mini < maxi) + + let in_range = QCheck.int_range mini maxi +- let pos_int = QCheck.map_same_type abs in_range ++ let pos_range = QCheck.int_range 0 maxi ++ let pos_int = QCheck.map_same_type abs pos_range + let in_range_float = + QCheck.float_range (float_of_int mini) (float_of_int maxi) + end +@@ -60,9 +61,11 @@ struct + test "An integer should perform logical-not correctly" + pos_int (fun x -> lognot (of_int x) = of_int (lnot x)) ; + ++ (* Test is broken for Int64, Uint64, Int128, and Uint128 + test "An integer should perform left-shifts correctly" + QCheck.(pair in_range (int_bound 31)) (fun (x, y) -> + shift_left (of_int x) y = of_int (x lsl y)) ; ++ *) + + test "An integer should perform right-shifts correctly" + QCheck.(pair in_range (int_bound 31)) (fun (x, y) -> +@@ -73,10 +76,12 @@ struct + let v = shift_right min_int i in + (compare min_int zero) *** (compare v zero) >= 0) ; + ++ (* Test is broken for Int128 + test "Logical shifts must not sign-extend" + QCheck.(int_range 0 200) (fun i -> + let v = shift_right_logical min_int i in + compare v zero >= 0) ; ++ *) + + test "An integer should perform float conversions correctly" + in_range_float (fun x -> diff --git a/ocaml-stdint.spec b/ocaml-stdint.spec index 89b7ef1..04013cc 100644 --- a/ocaml-stdint.spec +++ b/ocaml-stdint.spec @@ -5,17 +5,25 @@ %global srcname stdint Name: ocaml-%{srcname} -Version: 0.6.0 -Release: 9%{?dist}.1 +Version: 0.7.0 +Release: 1%{?dist} Summary: Various signed and unsigned integers for OCaml License: MIT URL: https://github.com/andrenth/%{name} Source0: %{url}/releases/download/%{version}/%{srcname}-%{version}.tbz +# Fix lognot and logxor for Int40, Int48, Int56, and Int128 +# https://github.com/andrenth/ocaml-stdint/pull/60 +Patch0: %{name}-lognot.patch +# Fix or disable broken tests +# https://github.com/andrenth/ocaml-stdint/issues/59 +Patch1: %{name}-test.patch -BuildRequires: ocaml >= 4.07 -BuildRequires: ocaml-dune >= 1.11 +BuildRequires: ocaml >= 4.03 +BuildRequires: ocaml-dune >= 1.10 BuildRequires: ocaml-odoc +BuildRequires: ocaml-ounit-devel +BuildRequires: ocaml-qcheck-devel %description The stdint library provides signed and unsigned integer types of various @@ -45,10 +53,10 @@ BuildArch: noarch Documentation for %{name}. %prep -%autosetup -n %{srcname}-%{version} +%autosetup -n %{srcname}-%{version} -p1 %build -dune build %{?_smp_mflags} +dune build %{?_smp_mflags} --display=verbose dune build %{?_smp_mflags} @doc # Relink the stublib with RPM_LD_FLAGS @@ -108,6 +116,10 @@ dune runtest %license LICENSE %changelog +* Wed Dec 2 2020 Jerry James - 0.7.0-1 +- Version 0.7.0 +- Add -lognot and -test patches + * Wed Sep 02 2020 Richard W.M. Jones - 0.6.0-9.1 - Bump release and rebuild. diff --git a/sources b/sources index e639788..cac0e87 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (stdint-0.6.0.tbz) = 00d1f864d0f353c4922c4c743df209893e3558a7cee9a1e7e51be5da691657ad5f1d22acf8bee583573c08166f8b2705632fd955e100dd0dea8be4e9d2fbcc48 +SHA512 (stdint-0.7.0.tbz) = 9b05b6cf691320b718dd2118b1e3f96a2997e42e6c99a34b470b060c82fc16c50d57c6ee392d1b62bdb8df73094657eea56050da3e74745a4afb0f150a60a584