nisdb_rw.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#ifndef _NISDB_RW_H
#define _NISDB_RW_H
#include <pthread.h>
#include <thread.h>
#include <synch.h>
#include <stdlib.h>
#include <malloc.h>
#ifdef __cplusplus
extern "C" {
#endif
#define INV_PTHREAD_ID 0
/*
* DEFAULTNISDBRWLOCK_RW is the default initializer that does _not_
* force read lock requests to write locks, while DEFAULTNISDBRWLOCK_W
* does force all locks to be exclusive.
*
* Locks should be initialized DEFAULTNISDBRWLOCK_W until it's been
* determined that non-exclusive locking can be safely used; see
* comments in __nisdb_rwinit() in nisdb_rw.c.
*/
0, {INV_PTHREAD_ID, 0, 0, 0}, \
0, 0, {INV_PTHREAD_ID, 0, 0, 0}}
0, {INV_PTHREAD_ID, 0, 0, 0}, \
0, 0, {INV_PTHREAD_ID, 0, 0, 0}}
/*
* The value used for the 'force_write' field initialization in
* __nisdb_rwinit(). Should be one unless it's been determined that
* read locks can safely be used in for _all_ locks initialized
* by __nisdb_rwinit().
*/
#define NISDB_FORCE_WRITE 1
#ifdef NISDB_MT_DEBUG
} else \
abort();
} else \
abort();
abort();
!= 0) \
abort();
!= 0) \
abort();
#else /* NISDB_MT_DEBUG */
#define ASSERTMUTEXHELD(var)
#define ASSERTWHELD(var)
#define ASSERTRHELD(var)
#endif /* NISDB_MT_DEBUG */
/* Nesting-safe RW locking */
typedef struct __nisdb_rwlock {
} __nisdb_rl_t;
typedef struct {
extern int __nisdb_rwinit(__nisdb_rwlock_t *);
extern int __nisdb_wlock(__nisdb_rwlock_t *);
extern int __nisdb_wlock_trylock(__nisdb_rwlock_t *, int);
extern int __nisdb_rlock(__nisdb_rwlock_t *);
extern int __nisdb_wulock(__nisdb_rwlock_t *);
extern int __nisdb_rulock(__nisdb_rwlock_t *);
extern int __nisdb_assert_wheld(__nisdb_rwlock_t *);
extern int __nisdb_assert_rheld(__nisdb_rwlock_t *);
extern int __nisdb_destroy_lock(__nisdb_rwlock_t *);
#ifdef __cplusplus
}
#endif
#endif /* _NISDB_RW_H */