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
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.
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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _NIS_HASHITEM_H
28 #define _NIS_HASHITEM_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 #include <rpcsvc/nis.h>
41 /* Private versions of the various NIS_HASH_ITEM functions */
42 typedef struct __nis_item_item
{
47 pthread_t last_reader_id
;
50 struct __nis_item_item
*next
;
51 struct __nis_item_item
*prv_item
;
52 struct __nis_item_item
*nxt_item
;
58 pthread_mutex_t traverser_id_lock
;
60 * Protects 'traversed'
64 pthread_t traverser_id
;
65 uint32_t locked_items
;
66 __nis_hash_item_mt
*keys
[64];
67 __nis_hash_item_mt
*first
;
68 void (*destroyItem
)(void *);
69 } __nis_hash_table_mt
;
71 #define NIS_HASH_TABLE_MT_INIT { \
72 PTHREAD_MUTEX_INITIALIZER, \
74 PTHREAD_MUTEX_INITIALIZER \
75 /* Zero is fine for the rest */ \
78 #define LOCK_LIST(list, msg) (void) __nis_lock_hash_table(list, 1, msg)
79 #define ULOCK_LIST(list, msg) (void) __nis_ulock_hash_table(list, 1, msg)
82 extern void __nis_init_hash_table(__nis_hash_table_mt
*, void (*)(void *));
83 extern int __nis_lock_hash_table(__nis_hash_table_mt
*, int, char *);
84 extern int __nis_ulock_hash_table(__nis_hash_table_mt
*, int, char *);
85 extern int __nis_insert_item_mt(void *, __nis_hash_table_mt
*, int);
86 extern void __nis_insert_name_mt(nis_name
, __nis_hash_table_mt
*);
87 extern void *__nis_find_item_mt(nis_name
, __nis_hash_table_mt
*, int,
89 extern void *__nis_pop_item_mt(__nis_hash_table_mt
*);
90 extern void *__nis_remove_item_mt(nis_name
, __nis_hash_table_mt
*);
91 extern int __nis_release_item(void *, __nis_hash_table_mt
*, int);
92 extern int __nis_item_access(void *);
93 extern void __nis_scan_table_mt(__nis_hash_table_mt
*,
94 bool_t (*)(__nis_hash_item_mt
*, void *), void *);
97 #define NIS_HASH_ITEM __nis_hash_item_mt
98 #define NIS_HASH_TABLE __nis_hash_table_mt
99 #define nis_insert_item(i, t) __nis_insert_item_mt(i, t, -1)
100 #define nis_insert_item_rw(i, t, rw) __nis_insert_item_mt(i, t, rw)
101 #define nis_insert_name(n, t) __nis_insert_name_mt(n, t)
102 #define nis_find_item(i, t) __nis_find_item_mt(i, t, -1, 0)
103 #define nis_find_item_rw(i, t, rw) __nis_find_item_mt(i, t, rw, 0)
104 #define nis_pop_item __nis_pop_item_mt
105 #define nis_remove_item __nis_remove_item_mt
106 #define nis_scan_table __nis_scan_table_mt
108 #define MT_LOCK_TYPE(type) (type < 0)?"W":(type > 0)?"R":"N"
111 #define MT_LOG(condition, syslogarg) if (condition) syslog ## syslogarg
113 #define MT_LOG(condition, syslogarg)
114 #endif /* NIS_MT_DEBUG */
118 #endif /* __cplusplus */
120 #endif /* _NIS_HASHITEM_H */