diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2000-04-07 14:43:31 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2000-04-07 14:43:31 +0000 |
commit | d3c45d93f083cf7d30b54f682f0fcf6141d9ae58 (patch) | |
tree | d830b44a08364ca87e267484760082c131260da3 /byterun/hash.c | |
parent | d2d789e8a8ed6f8a7d2816f7fc70c1d53bd4553a (diff) |
Ajout de hash_variant (pour manipuler des variantes depuis C)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3048 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/hash.c')
-rw-r--r-- | byterun/hash.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/byterun/hash.c b/byterun/hash.c index af756eaf2..114d9d69c 100644 --- a/byterun/hash.c +++ b/byterun/hash.c @@ -131,3 +131,18 @@ static void hash_aux(value obj) a priori unknown structure. Use its physical address as hash key. */ Combine((long) obj); } + +/* Hashing variant tags */ + +value hash_variant(char * tag) +{ + value accu; + /* Same hashing algorithm as in ../typing/btype.ml, function hash_variant */ + for (accu = Val_int(0); *tag != 0; tag++) + accu = Val_int(223 * Int_val(accu) + *((unsigned char *) tag)); + accu = accu & Val_int((1 << 31) - 1); + /* Force sign extension of bit 31 for compatibility between 32 and 64-bit + platforms */ + return (int32) accu; +} + |