Package: unison2.32.52 / 2.32.52-7

0008-OCaml-4-hash-compatibility.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
From: Stephane Glondu <steph@glondu.net>
Date: Sat, 11 May 2013 12:22:15 +0200
Subject: OCaml 4 hash compatibility

This is a backport of a patch introduced in Unison 2.40.102.

Signed-off-by: Stephane Glondu <steph@glondu.net>
---
 name.ml     |    2 +-
 path.ml     |    2 --
 path.mli    |    1 -
 props.ml    |    6 +++---
 update.ml   |    4 ++--
 uutil.ml    |    4 ++++
 uutil.mli   |    2 ++
 xferhint.ml |    4 ++--
 8 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/name.ml b/name.ml
index 020c496..3de893b 100644
--- a/name.ml
+++ b/name.ml
@@ -42,4 +42,4 @@ let fromString s =
   s
 
 let hash n =
-  Hashtbl.hash (if Case.insensitive () then String.lowercase (Case.normalize n) else n)
+  Uutil.hash (if Case.insensitive () then String.lowercase (Case.normalize n) else n)
diff --git a/path.ml b/path.ml
index fb05bc3..05f9f3c 100644
--- a/path.ml
+++ b/path.ml
@@ -191,8 +191,6 @@ let addPrefixToFinalName path prefix =
     assert (not (isEmpty path));
     prefix ^ path
 
-let hash p = Hashtbl.hash p
-
 (* Pref controlling whether symlinks are followed. *)
 let follow = Pred.create "follow"
     ("Including the preference \\texttt{-follow \\ARG{pathspec}} causes Unison to \
diff --git a/path.mli b/path.mli
index dd75b05..5113fdd 100644
--- a/path.mli
+++ b/path.mli
@@ -31,7 +31,6 @@ val addSuffixToFinalName : local -> string -> local
 val addPrefixToFinalName : local -> string -> local
 
 val compare : t -> t -> int
-val hash : local -> int
 
 val followLink : local -> bool
 
diff --git a/props.ml b/props.ml
index c4b9b84..8fad0b9 100644
--- a/props.ml
+++ b/props.ml
@@ -277,7 +277,7 @@ let hash id h =
     (match id with
        IdIgnored   -> -1
      | IdNumeric i -> i
-     | IdNamed nm  -> Hashtbl.hash nm)
+     | IdNamed nm  -> Uutil.hash nm)
     h
 
 let similar id id' =
@@ -429,7 +429,7 @@ let moduloOneHour t =
 let hash t h =
   Uutil.hash2
     (match t with
-       Synced f    -> Hashtbl.hash (moduloOneHour (approximate f))
+       Synced f    -> Uutil.hash (moduloOneHour (approximate f))
      | NotSynced _ -> 0)
     h
 
@@ -597,7 +597,7 @@ type t = string option
 
 let dummy = None
 
-let hash t h = Uutil.hash2 (Hashtbl.hash t) h
+let hash t h = Uutil.hash2 (Uutil.hash t) h
 
 let similar t t' =
   not (Prefs.read Osx.rsrc) || t = t'
diff --git a/update.ml b/update.ml
index 5e58f65..493bf7f 100644
--- a/update.ml
+++ b/update.ml
@@ -234,9 +234,9 @@ let rec checkArchive (top: bool) (path: Path.t) (arch: archive) (h: int): int =
                        (checkArchive false (Path.child path n) a h))
         children (Props.hash desc h)
   | ArchiveFile (desc, dig, _, ress) ->
-      Uutil.hash2 (Hashtbl.hash dig) (Props.hash desc h)
+      Uutil.hash2 (Uutil.hash dig) (Props.hash desc h)
   | ArchiveSymlink content ->
-      Uutil.hash2 (Hashtbl.hash content) h
+      Uutil.hash2 (Uutil.hash content) h
   | NoArchive ->
       135
 
diff --git a/uutil.ml b/uutil.ml
index 84d8762..75cf8cb 100644
--- a/uutil.ml
+++ b/uutil.ml
@@ -34,6 +34,10 @@ let myNameAndVersion = myName ^ " " ^ myVersion
 
 let hash2 x y = (17 * x + 257 * y) land 0x3FFFFFFF
 
+external hash_param : int -> int -> 'a -> int = "caml_hash_univ_param" "noalloc"
+
+let hash x = hash_param 10 100 x
+
 (*****************************************************************************)
 (*                             File sizes                                    *)
 (*****************************************************************************)
diff --git a/uutil.mli b/uutil.mli
index 369e577..f7dd78e 100644
--- a/uutil.mli
+++ b/uutil.mli
@@ -13,6 +13,8 @@ val myNameAndVersion : string
 
 (* Hashing *)
 val hash2 : int -> int -> int
+(* Hash function (OCaml 3.x version) *)
+val hash : 'a -> int
 
 module type FILESIZE = sig
   type t
diff --git a/xferhint.ml b/xferhint.ml
index abe3dd6..ad74fb4 100644
--- a/xferhint.ml
+++ b/xferhint.ml
@@ -32,7 +32,7 @@ module PathMap =
     (struct
        type t = Fspath.t * Path.local
        let hash (fspath, path) =
-         (Hashtbl.hash (Fspath.toString fspath) + 13217 * Path.hash path)
+         (Uutil.hash (Fspath.toString fspath) + 13217 * Uutil.hash path)
            land
          0x3FFFFFFF
        let equal = (=)
@@ -41,7 +41,7 @@ module FPMap =
   Hashtbl.Make
     (struct
        type t = Os.fullfingerprint
-       let hash = Hashtbl.hash
+       let hash = Uutil.hash
        let equal = (=)
      end)
 
--