]> sourceware.org Git - glibc.git/blob - db2/lock/lock_util.c
Update.
[glibc.git] / db2 / lock / lock_util.c
1 /*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 1996, 1997
5 * Sleepycat Software. All rights reserved.
6 */
7
8 #include "config.h"
9
10 #ifndef lint
11 static const char sccsid[] = "@(#)lock_util.c 10.4 (Sleepycat) 7/22/97";
12 #endif /* not lint */
13
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
16
17 #include <fcntl.h>
18 #include <stddef.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <unistd.h>
23 #endif
24
25 #include "db_int.h"
26 #include "shqueue.h"
27 #include "db_page.h"
28 #include "db_shash.h"
29 #include "hash.h"
30 #include "lock.h"
31
32 /*
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 *));
39 */
40 int
41 __lock_cmp(dbt, lock_obj)
42 DBT *dbt;
43 DB_LOCKOBJ *lock_obj;
44 {
45 void *obj_data;
46
47 if (lock_obj->type != DB_LOCK_OBJTYPE)
48 return (0);
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);
52 }
53
54 /*
55 * PUBLIC: int __lock_locker_cmp __P((u_int32_t, DB_LOCKOBJ *));
56 */
57 int
58 __lock_locker_cmp(locker, lock_obj)
59 u_int32_t locker;
60 DB_LOCKOBJ *lock_obj;
61 {
62 void *obj_data;
63
64 if (lock_obj->type != DB_LOCK_LOCKER)
65 return (0);
66
67 obj_data = SH_DBT_PTR(&lock_obj->lockobj);
68 return (memcmp(&locker, obj_data, sizeof(u_int32_t)) == 0);
69 }
70
71 /*
72 * PUBLIC: int __lock_ohash __P((DBT *));
73 */
74 int
75 __lock_ohash(dbt)
76 DBT *dbt;
77 {
78 return (__ham_func5(dbt->data, dbt->size));
79 }
80
81 /*
82 * PUBLIC: u_int32_t __lock_locker_hash __P((u_int32_t));
83 */
84 u_int32_t
85 __lock_locker_hash(locker)
86 u_int32_t locker;
87 {
88 return (__ham_func5(&locker, sizeof(locker)));
89 }
90
91 /*
92 * PUBLIC: u_int32_t __lock_lhash __P((DB_LOCKOBJ *));
93 */
94 u_int32_t
95 __lock_lhash(lock_obj)
96 DB_LOCKOBJ *lock_obj;
97 {
98 void *obj_data;
99
100 obj_data = SH_DBT_PTR(&lock_obj->lockobj);
101 return (__ham_func5(obj_data, lock_obj->lockobj.size));
102 }
103
This page took 0.040321 seconds and 5 git commands to generate.