xref: /titanic_50/usr/src/lib/libnisdb/yptol/shim_lockmap.c (revision 34f9b3eef6fdadbda0a846aa4d68691ac40eace5)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * DESCRIPTION: Contains a front end to the map locking code. These are called
31  *		when a map, or its map_ctrl structure, needs to be locked
32  *		for a short time for internal modification. This lock should
33  *		not be held between DBM operations.
34  *
35  * NOTE :	This is not the same mechanism as the `update lock` which is
36  *		held for a relatively long period when a map is being update
37  *		from the DIT.
38  */
39 
40 #include <unistd.h>
41 #include <syslog.h>
42 #include <sys/mman.h>
43 #include <thread.h>
44 #include <synch.h>
45 #include <ndbm.h>
46 #include "ypsym.h"
47 #include "shim.h"
48 
49 /*
50  * FUNCTION : 	lock_map_ctrl()
51  *
52  * DESCRIPTION: Front end to the lock routine taking map_ctrl structure as
53  *		argument. Saves cost of a hash operation.
54  *
55  * GIVEN :	Map_ctrl structure .
56  *
57  * RETURNS :	Same as lock core
58  */
59 int
60 lock_map_ctrl(map_ctrl *map)
61 {
62 	int ret;
63 
64 	ret = lock_core(map->hash_val);
65 
66 	return (ret);
67 }
68 
69 /*
70  * FUNCTION : 	unlock_map_ctrl()
71  *
72  * DESCRIPTION: Front end to the unlock routine taking map_ctrl structure as
73  *		argument. Saves cost of a hash operation.
74  *
75  * GIVEN :	Map_ctrl structure .
76  *
77  * RETURNS :	Same as lock core
78  */
79 int
80 unlock_map_ctrl(map_ctrl *map)
81 {
82 	int ret;
83 
84 	ret = unlock_core(map->hash_val);
85 	return (ret);
86 }
87