diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2001-07-24 09:05:25 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2001-07-24 09:05:25 +0000 |
commit | 9ce02c4cc3cd485fd0f9778e68995c136b843945 (patch) | |
tree | 5621d4b7f1147ebcac3b478a414b6618384c8b38 /otherlibs/win32unix/unixsupport.c | |
parent | 3dbeaba2513f003aebcd524a0eed2310a26b83fc (diff) |
Ajout comparaisons et hashing sur les handles (PR#439). A tester
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3596 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/win32unix/unixsupport.c')
-rw-r--r-- | otherlibs/win32unix/unixsupport.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/otherlibs/win32unix/unixsupport.c b/otherlibs/win32unix/unixsupport.c index fa957d4de..69d3106be 100644 --- a/otherlibs/win32unix/unixsupport.c +++ b/otherlibs/win32unix/unixsupport.c @@ -17,6 +17,7 @@ #include <alloc.h> #include <memory.h> #include <fail.h> +#include <custom.h> #include "unixsupport.h" #include "cst2constr.h" #include <errno.h> @@ -24,9 +25,31 @@ /* Heap-allocation of Windows file handles */ +static int win_handle_compare(value v1, value v2) +{ + HANDLE h1 = Handle_val(v1); + HANDLE h2 = Handle_val(v2); + return h1 == h2 ? 0 : h1 < h2 ? -1 : 1; +} + +static long win_handle_hash(value v) +{ + return (long) Handle_val(v); +} + +static struct custom_operations win_handle_ops = { + "_handle", + custom_finalize_default, + win_handle_compare, + win_handle_hash, + custom_serialize_default, + custom_deserialize_default +}; + value win_alloc_handle(HANDLE h) { - value res = alloc_small(sizeof(HANDLE) / sizeof(value), Abstract_tag); + value res = + alloc_custom(&win_handle_ops, sizeof(HANDLE), 0, 1); Handle_val(res) = h; return res; } |