diff options
-rw-r--r-- | byterun/ints.c | 9 | ||||
-rw-r--r-- | byterun/io.c | 10 | ||||
-rw-r--r-- | otherlibs/bigarray/bigarray_stubs.c | 3 | ||||
-rw-r--r-- | otherlibs/graph/image.c | 3 | ||||
-rw-r--r-- | otherlibs/num/nat_stubs.c | 19 | ||||
-rw-r--r-- | otherlibs/systhreads/st_stubs.c | 33 | ||||
-rw-r--r-- | otherlibs/win32graph/draw.c | 3 | ||||
-rw-r--r-- | otherlibs/win32unix/unixsupport.c | 3 |
8 files changed, 65 insertions, 18 deletions
diff --git a/byterun/ints.c b/byterun/ints.c index b15de09ec..a9f224c2b 100644 --- a/byterun/ints.c +++ b/byterun/ints.c @@ -227,7 +227,8 @@ CAMLexport struct custom_operations caml_int32_ops = { int32_cmp, int32_hash, int32_serialize, - int32_deserialize + int32_deserialize, + custom_compare_ext_default }; CAMLexport value caml_copy_int32(int32 i) @@ -414,7 +415,8 @@ CAMLexport struct custom_operations caml_int64_ops = { int64_cmp, int64_hash, int64_serialize, - int64_deserialize + int64_deserialize, + custom_compare_ext_default }; CAMLexport value caml_copy_int64(int64 i) @@ -665,7 +667,8 @@ CAMLexport struct custom_operations caml_nativeint_ops = { nativeint_cmp, nativeint_hash, nativeint_serialize, - nativeint_deserialize + nativeint_deserialize, + custom_compare_ext_default }; CAMLexport value caml_copy_nativeint(intnat i) diff --git a/byterun/io.c b/byterun/io.c index e7c7f0485..8d95ef70d 100644 --- a/byterun/io.c +++ b/byterun/io.c @@ -431,13 +431,19 @@ static int compare_channel(value vchan1, value vchan2) return (chan1 == chan2) ? 0 : (chan1 < chan2) ? -1 : 1; } +static intnat hash_channel(value vchan) +{ + return (intnat) (Channel(vchan)); +} + static struct custom_operations channel_operations = { "_chan", caml_finalize_channel, compare_channel, - custom_hash_default, + hash_channel, custom_serialize_default, - custom_deserialize_default + custom_deserialize_default, + custom_compare_ext_default }; CAMLexport value caml_alloc_channel(struct channel *chan) diff --git a/otherlibs/bigarray/bigarray_stubs.c b/otherlibs/bigarray/bigarray_stubs.c index 787b99e12..e7bee339b 100644 --- a/otherlibs/bigarray/bigarray_stubs.c +++ b/otherlibs/bigarray/bigarray_stubs.c @@ -76,7 +76,8 @@ static struct custom_operations caml_ba_ops = { caml_ba_compare, caml_ba_hash, caml_ba_serialize, - caml_ba_deserialize + caml_ba_deserialize, + custom_compare_ext_default }; /* Multiplication of unsigned longs with overflow detection */ diff --git a/otherlibs/graph/image.c b/otherlibs/graph/image.c index 501398b35..a337de348 100644 --- a/otherlibs/graph/image.c +++ b/otherlibs/graph/image.c @@ -30,7 +30,8 @@ static struct custom_operations image_ops = { custom_compare_default, custom_hash_default, custom_serialize_default, - custom_deserialize_default + custom_deserialize_default, + custom_compare_ext_default }; #define Max_image_mem 2000000 diff --git a/otherlibs/num/nat_stubs.c b/otherlibs/num/nat_stubs.c index cffe12374..18cbdd2e4 100644 --- a/otherlibs/num/nat_stubs.c +++ b/otherlibs/num/nat_stubs.c @@ -18,6 +18,7 @@ #include "custom.h" #include "intext.h" #include "fail.h" +#include "hash.h" #include "memory.h" #include "mlvalues.h" @@ -26,6 +27,7 @@ /* Stub code for the Nat module. */ +static intnat hash_nat(value); static void serialize_nat(value, uintnat *, uintnat *); static uintnat deserialize_nat(void * dst); @@ -33,9 +35,10 @@ static struct custom_operations nat_operations = { "_nat", custom_finalize_default, custom_compare_default, - custom_hash_default, + hash_nat, serialize_nat, - deserialize_nat + deserialize_nat, + custom_compare_ext_default }; CAMLprim value initialize_nat(value unit) @@ -389,3 +392,15 @@ static uintnat deserialize_nat(void * dst) #endif return len * 4; } + +static intnat hash_nat(value v) +{ + mlsize_t len = Wosize_val(v) - 1; + mlsize_t i; + uint32 h = len; + for (i = 0; i < len; i++) { + h = caml_hash_mix_intnat(h, Digit_val(v, i)); + } + return h; +} + diff --git a/otherlibs/systhreads/st_stubs.c b/otherlibs/systhreads/st_stubs.c index fbef6ea05..54cbb4e8c 100644 --- a/otherlibs/systhreads/st_stubs.c +++ b/otherlibs/systhreads/st_stubs.c @@ -685,18 +685,23 @@ static void caml_mutex_finalize(value wrapper) st_mutex_destroy(Mutex_val(wrapper)); } -static int caml_mutex_condition_compare(value wrapper1, value wrapper2) +static int caml_mutex_compare(value wrapper1, value wrapper2) { st_mutex mut1 = Mutex_val(wrapper1); st_mutex mut2 = Mutex_val(wrapper2); return mut1 == mut2 ? 0 : mut1 < mut2 ? -1 : 1; } +static intnat caml_mutex_hash(value wrapper) +{ + return (intnat) (Mutex_val(wrapper)); +} + static struct custom_operations caml_mutex_ops = { "_mutex", caml_mutex_finalize, - caml_mutex_condition_compare, - custom_hash_default, + caml_mutex_compare, + caml_mutex_hash, custom_serialize_default, custom_deserialize_default }; @@ -759,13 +764,26 @@ static void caml_condition_finalize(value wrapper) st_condvar_destroy(Condition_val(wrapper)); } +static int caml_condition_compare(value wrapper1, value wrapper2) +{ + st_condvar cond1 = Condition_val(wrapper1); + st_condvar cond2 = Condition_val(wrapper2); + return cond1 == cond2 ? 0 : cond1 < cond2 ? -1 : 1; +} + +static intnat caml_condition_hash(value wrapper) +{ + return (intnat) (Condition_val(wrapper)); +} + static struct custom_operations caml_condition_ops = { "_condition", caml_condition_finalize, - caml_mutex_condition_compare, - custom_hash_default, + caml_condition_compare, + caml_condition_hash, custom_serialize_default, - custom_deserialize_default + custom_deserialize_default, + custom_compare_ext_default }; CAMLprim value caml_condition_new(value unit) /* ML */ @@ -824,7 +842,8 @@ static struct custom_operations caml_threadstatus_ops = { custom_compare_default, custom_hash_default, custom_serialize_default, - custom_deserialize_default + custom_deserialize_default, + custom_compare_ext_default }; static value caml_threadstatus_new (void) diff --git a/otherlibs/win32graph/draw.c b/otherlibs/win32graph/draw.c index 62710ec09..4bd60812a 100644 --- a/otherlibs/win32graph/draw.c +++ b/otherlibs/win32graph/draw.c @@ -452,7 +452,8 @@ static struct custom_operations image_ops = { custom_compare_default, custom_hash_default, custom_serialize_default, - custom_deserialize_default + custom_deserialize_default, + custom_compare_ext_default }; CAMLprim value caml_gr_create_image(value vw, value vh) diff --git a/otherlibs/win32unix/unixsupport.c b/otherlibs/win32unix/unixsupport.c index 2f545c19f..45d689ff6 100644 --- a/otherlibs/win32unix/unixsupport.c +++ b/otherlibs/win32unix/unixsupport.c @@ -44,7 +44,8 @@ static struct custom_operations win_handle_ops = { win_handle_compare, win_handle_hash, custom_serialize_default, - custom_deserialize_default + custom_deserialize_default, + custom_compare_ext_default }; value win_alloc_handle(HANDLE h) |