2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1996, 1997
5 * Sleepycat Software. All rights reserved.
11 static const char sccsid[] = "@(#)lock_util.c 10.4 (Sleepycat) 7/22/97";
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
33 * This function is used to compare a DBT that is about to be entered
34 * into a hash table with an object already in the hash table. Note
35 * that it just returns true on equal and 0 on not-equal. Therefore this
36 * cannot be used as a sort function; its purpose is to be used as a
37 * hash comparison function.
38 * PUBLIC: int __lock_cmp __P((DBT *, DB_LOCKOBJ *));
41 __lock_cmp(dbt, lock_obj)
47 if (lock_obj->type != DB_LOCK_OBJTYPE)
49 obj_data = SH_DBT_PTR(&lock_obj->lockobj);
50 return (dbt->size == lock_obj->lockobj.size &&
51 memcmp(dbt->data, obj_data, dbt->size) == 0);
55 * PUBLIC: int __lock_locker_cmp __P((u_int32_t, DB_LOCKOBJ *));
58 __lock_locker_cmp(locker, lock_obj)
64 if (lock_obj->type != DB_LOCK_LOCKER)
67 obj_data = SH_DBT_PTR(&lock_obj->lockobj);
68 return (memcmp(&locker, obj_data, sizeof(u_int32_t)) == 0);
72 * PUBLIC: int __lock_ohash __P((DBT *));
78 return (__ham_func5(dbt->data, dbt->size));
82 * PUBLIC: u_int32_t __lock_locker_hash __P((u_int32_t));
85 __lock_locker_hash(locker)
88 return (__ham_func5(&locker, sizeof(locker)));
92 * PUBLIC: u_int32_t __lock_lhash __P((DB_LOCKOBJ *));
95 __lock_lhash(lock_obj)
100 obj_data = SH_DBT_PTR(&lock_obj->lockobj);
101 return (__ham_func5(obj_data, lock_obj->lockobj.size));