/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "nscd_db.h"
#include "nscd_log.h"
/*
* Access control structure for a piece of nscd data. This structure
* is always tagged before the nscd data. nscd_alloc, which should
* be used to allocate memory that requires access control or usage
* count control, will initialize this access control structure at the
* start of the memory returned to the caller.
*/
struct nscd_access_s {
int type;
};
/* size should be in multiple of 8 */
#define ABORT_DUE_TO_NO_VALID_NSCD_ACCESS_DATA 0
#define ASSERT_ACCESS_DATA \
#define SET_ACCESS_PTR \
access = (nscd_access_t *) \
((void *)((char *)data - sizeof_access))
/*
* FUNCTION: _nscd_release
*
* Decrements the usage count maintained in the access data
* tagged before 'data'. Delete the nscd data item if the delete
* flag is set and the usage count reaches 0.
*/
void
{
return;
(me, "data = %p, access->data = %p, "
"seq = %lld, nUse = %d\n",
#define ACCESS_NUSE_LESS_THAN_ZERO 0
}
/*
* if we get here, no other thread could be
* holding the access->mutex lock, It is safe
* to free the memory containing the mutex
* structure. No mutex_unlock is necessary.
*/
} else
}
/*
* FUNCTION: _nscd_destroy
*
* Marks the nscd data item as to-be-deleted and then releases
* (If the usage count happens to be zero, then _nscd_release()
* will destroy the data.)
*
* Note that _nscd_destroy should only be called if the
* caller has created the nscd data with _nscd_alloc
* (with the exception of _nscd_set). That nscd data
* item should be private to the caller.
*/
static void
{
return;
}
/*
* FUNCTION: _nscd_get
*
* Increment the usage count by one if 'data' can
* be found in the internal address database.
*/
{
return (NULL);
(me, "data = %p, access->data = %p, seq#= %lld, nUse = %d\n",
/*
* see if this addr is still valid,
* if so, _nscd_is_int_addr will
* do a read lock on the returned
* to prevent the access data from being
* deleted while it is being accessed.
*/
return (NULL);
}
else
/*
*/
(void) rw_unlock(addr_rwlock);
return (ret);
}
/*
* FUNCTION: _nscd_set
*
* _nscd_set sets the address of a nscd data item
* to 'new' and delete the old nscd data (old).
* The pointer 'new' is returned.
*/
{
return (old);
return (new_data);
}
/* if old_data == new_data, both must be NULL */
return (NULL);
}
/*
* FUNCTION: _nscd_rdlock
*
* Lock (rw_rdlock) a nscd data item for reading. The caller
* needs to call _nscd_rw_unlock() to unlock the data item
* when done using the data.
*/
{
void *ret;
return (NULL);
return (ret);
}
/*
* FUNCTION: _nscd_wrlock
*
* Lock (rw_wrlock) a nscd data item for writing. The caller
* needs to call _nscd_rw_unlock() to unlock the data item
* when done using the data.
*/
{
void *ret;
return (NULL);
return (ret);
}
/*
* FUNCTION: _nscd_rw_unlock
*
* Unlock (rw_unlock) a locked nscd data item.
*/
void
{
return;
(me, "data = %p, access->data = %p\n",
}
/*
* FUNCTION: _nscd_rw_unlock_no_release
*
* Unlock (rw_unlock) a locked nscd data item but without release
* it, i.e., without decrement the usage count to indicate that
* the data item is still being referenced.
*/
void
{
return;
}
/*
* FUNCTION: _nscd_mutex_lock
*
* Lock (mutex_lock) a nscd data item. The caller needs
* to call _nscd_mutex_unlock() to unlock the data item
* when done using the data.
*/
{
void *ret;
return (NULL);
return (ret);
}
/*
* FUNCTION: _nscd_mutex_unlock
*
* Unlock a locked nscd data item (that were locked by _nscd_mutex_lock)..
*/
void
{
return;
}
/*
* FUNCTION: _nscd_cond_wait
*
* Perform a condition wait with the cond_t and mutex_t associated
* with data.
*/
void
{
return;
else
}
/*
* FUNCTION: _nscd_cond_signal
*
* Perform a condition signal with the cond_t associated with 'data'.
*/
void
{
return;
}
/*
* FUNCTION: _nscd_alloc
*
* Allocate a piece of nscd memory. 'data_free'
* is the function to invoke to free the data
* stored in this memory, i.e., the desctrctor.
* 'option' indicate whether a mutex or a
* be allocated.
*/
int type,
int option)
{
return (NULL);
if (option & NSCD_ALLOC_MUTEX) {
NULL) {
return (NULL);
} else
}
if (option & NSCD_ALLOC_RWLOCK) {
NULL) {
return (NULL);
} else
}
if (option & NSCD_ALLOC_COND) {
NULL) {
return (NULL);
} else
}
/* get current sequence number */
seq_num = _nscd_get_seq_num();
/* add the address to the internal address database */
seq_num) != NSCD_SUCCESS) {
return (NULL);
}
}
/*
* FUNCTION: _nscd_free
*
* Free a piece of nscd memory.
*/
static void
{
return;
/* remove the address from the internal address database */
if (access->data_mutex)
if (access->data_rwlock)
}