diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2011-07-23 10:07:25 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2011-07-23 10:07:25 +0000 |
commit | f90ddc8c22079e5f54c9c21f633c0d829f3218a2 (patch) | |
tree | 9b7e1dc7272fa1b553d5ea980973d9b22a9db7be /otherlibs/systhreads/st_stubs.c | |
parent | 8f5e85913493f813154079639c5c42d44fb11525 (diff) | |
download | ocaml-f90ddc8c22079e5f54c9c21f633c0d829f3218a2.tar.gz |
PR#5290: added hash functions for channels, nats, mutexes, conditions.
Also: added "custom_compare_ext_default" to all struct custom_operations:
default initialization to 0 did what we want, but explicit initialization
better documents the C sources.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11143 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/systhreads/st_stubs.c')
-rw-r--r-- | otherlibs/systhreads/st_stubs.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/otherlibs/systhreads/st_stubs.c b/otherlibs/systhreads/st_stubs.c index fbef6ea051..54cbb4e8c3 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) |