#ifndef _NIS_HASHITEM_H
#define _NIS_HASHITEM_H
#include <pthread.h>
#include <rpcsvc/nis.h>
#include "nisdb_rw.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct __nis_item_item {
pthread_cond_t lock;
nis_name name;
int keychain;
uint32_t readers;
pthread_t last_reader_id;
uint32_t writer;
pthread_t writer_id;
struct __nis_item_item *next;
struct __nis_item_item *prv_item;
struct __nis_item_item *nxt_item;
} __nis_hash_item_mt;
typedef struct {
pthread_mutex_t lock;
pthread_cond_t cond;
pthread_mutex_t traverser_id_lock;
uint32_t traversed;
pthread_t traverser_id;
uint32_t locked_items;
__nis_hash_item_mt *keys[64];
__nis_hash_item_mt *first;
void (*destroyItem)(void *);
} __nis_hash_table_mt;
#define NIS_HASH_TABLE_MT_INIT { \
PTHREAD_MUTEX_INITIALIZER, \
{0}, \
PTHREAD_MUTEX_INITIALIZER \
\
}
#define LOCK_LIST(list, msg) (void) __nis_lock_hash_table(list, 1, msg)
#define ULOCK_LIST(list, msg) (void) __nis_ulock_hash_table(list, 1, msg)
extern void __nis_init_hash_table(__nis_hash_table_mt *, void (*)(void *));
extern int __nis_lock_hash_table(__nis_hash_table_mt *, int, char *);
extern int __nis_ulock_hash_table(__nis_hash_table_mt *, int, char *);
extern int __nis_insert_item_mt(void *, __nis_hash_table_mt *, int);
extern void __nis_insert_name_mt(nis_name, __nis_hash_table_mt *);
extern void *__nis_find_item_mt(nis_name, __nis_hash_table_mt *, int,
int *);
extern void *__nis_pop_item_mt(__nis_hash_table_mt *);
extern void *__nis_remove_item_mt(nis_name, __nis_hash_table_mt *);
extern int __nis_release_item(void *, __nis_hash_table_mt *, int);
extern int __nis_item_access(void *);
extern void __nis_scan_table_mt(__nis_hash_table_mt *,
bool_t (*)(__nis_hash_item_mt *, void *), void *);
#define NIS_HASH_ITEM __nis_hash_item_mt
#define NIS_HASH_TABLE __nis_hash_table_mt
#define nis_insert_item(i, t) __nis_insert_item_mt(i, t, -1)
#define nis_insert_item_rw(i, t, rw) __nis_insert_item_mt(i, t, rw)
#define nis_insert_name(n, t) __nis_insert_name_mt(n, t)
#define nis_find_item(i, t) __nis_find_item_mt(i, t, -1, 0)
#define nis_find_item_rw(i, t, rw) __nis_find_item_mt(i, t, rw, 0)
#define nis_pop_item __nis_pop_item_mt
#define nis_remove_item __nis_remove_item_mt
#define nis_scan_table __nis_scan_table_mt
#define MT_LOCK_TYPE(type) (type < 0)?"W":(type > 0)?"R":"N"
#ifdef NIS_MT_DEBUG
#define MT_LOG(condition, syslogarg) if (condition) syslog ## syslogarg
#else
#define MT_LOG(condition, syslogarg)
#endif
#ifdef __cplusplus
}
#endif
#endif