/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright 2011 Jason King. All rights reserved.
*/
#include "libuutil_common.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/*
* uu_list_index_ts define a location for insertion. They are simply a
* pointer to the object after the insertion point. We store a mark
* in the low-bits of the index, to help prevent mistakes.
*
* When debugging, the index mark changes on every insert and delete, to
* catch stale references.
*/
{
return (NULL);
}
if (flags & ~UU_LIST_POOL_DEBUG) {
return (NULL);
}
return (NULL);
}
if (flags & UU_LIST_POOL_DEBUG)
pp->ulp_last_index = 0;
(void) pthread_mutex_lock(&uu_lpool_list_lock);
(void) pthread_mutex_unlock(&uu_lpool_list_lock);
return (pp);
}
void
{
uu_panic("uu_list_pool_destroy: Pool \"%.*s\" (%p) has "
"outstanding lists, or is corrupt.\n",
(void *)pp);
}
}
(void) pthread_mutex_lock(&uu_lpool_list_lock);
(void) pthread_mutex_unlock(&uu_lpool_list_lock);
}
void
{
uu_panic("uu_list_node_init(%p, %p, %p (\"%s\")): "
"offset %ld doesn't fit in object (size %ld)\n",
}
uu_panic("uu_list_node_init(%p, %p, %p (\"%s\")): "
"offset %ld doesn't match pool's offset (%ld)\n",
}
}
}
void
{
uu_panic("uu_list_node_fini(%p, %p, %p (\"%s\")): "
"node already finied\n",
}
uu_panic("uu_list_node_fini(%p, %p, %p (\"%s\")): "
"node corrupt or on list\n",
}
}
}
{
return (NULL);
}
uu_panic("uu_list_create(%p, ...): requested "
"UU_LIST_SORTED, but pool has no comparison func\n",
(void *)pp);
return (NULL);
}
return (NULL);
}
lp->ul_numnodes = 0;
return (lp);
}
void
{
uu_panic("uu_list_destroy(%p): list not empty\n",
(void *)lp);
}
if (lp->ul_numnodes != 0) {
uu_panic("uu_list_destroy(%p): numnodes is nonzero, "
"but list is empty\n", (void *)lp);
}
uu_panic("uu_list_destroy(%p): outstanding walkers\n",
(void *)lp);
}
}
}
static void
{
uu_panic("insert(%p): internal error: %p and %p not "
(void *)prev);
uu_panic("insert(%p): elem %p node %p corrupt, "
"not initialized, or already in a list.\n",
}
/*
* invalidate outstanding uu_list_index_ts.
*/
}
lp->ul_numnodes++;
}
void
{
uu_panic("uu_list_insert(%p, %p, %p): %s\n",
"invalid index");
uu_panic("uu_list_insert(%p, %p, %p): out-of-date "
}
}
void *
{
*out = 0;
return (NULL);
}
if (cmp == 0) {
return (ep);
}
return (NULL);
}
}
return (NULL);
}
void *
{
uu_panic("uu_list_nearest_next(%p, %p): %s\n",
"invalid index");
uu_panic("uu_list_nearest_next(%p, %p): out-of-date "
}
return (NULL);
else
}
void *
{
uu_panic("uu_list_nearest_prev(%p, %p): %s\n",
"outdated index" : "invalid index");
uu_panic("uu_list_nearest_prev(%p, %p): out-of-date "
}
return (NULL);
else
}
static void
{
if (direction > 0)
else
/*
* Add this walker to the list's list of walkers so
* uu_list_remove() can advance us if somebody tries to
* remove ulw_next_result.
*/
}
}
static uu_list_node_impl_t *
{
return (NULL);
return (np);
}
static void
{
/* GLXXX debugging? */
}
}
{
return (NULL);
}
return (NULL);
}
return (wp);
}
void *
{
return (NULL);
}
void
{
}
int
{
return (-1);
}
void *e;
while (status == UU_WALK_NEXT &&
} else {
if (!reverse) {
}
} else {
}
}
}
if (status >= 0)
return (0);
return (-1);
}
void
{
uu_panic("uu_list_remove(%p, %p): elem not on list\n",
/*
* invalidate outstanding uu_list_index_ts.
*/
}
/*
* robust walkers must be advanced. In debug mode, non-robust
* walkers are also on the list. If there are any, it's an error.
*/
if (wp->ulw_robust) {
uu_panic("uu_list_remove(%p, %p): active non-robust "
}
}
lp->ul_numnodes--;
}
void *
{
void *ep;
/*
* XXX: disable list modification until list is empty
*/
uu_panic("uu_list_teardown(%p, %p): unexpected cookie\n",
if (ep)
return (ep);
}
int
{
uu_panic("uu_list_insert_before(%p, %p, %p): %p is "
"not currently on a list\n",
}
uu_panic("uu_list_insert_before(%p, ...): list is "
"UU_LIST_SORTED\n", (void *)lp);
return (-1);
}
return (0);
}
int
{
uu_panic("uu_list_insert_after(%p, %p, %p): %p is "
"not currently on a list\n",
}
uu_panic("uu_list_insert_after(%p, ...): list is "
"UU_LIST_SORTED\n", (void *)lp);
return (-1);
}
return (0);
}
{
return (lp->ul_numnodes);
}
void *
{
if (n == &lp->ul_null_node)
return (NULL);
return (NODE_TO_ELEM(lp, n));
}
void *
{
if (n == &lp->ul_null_node)
return (NULL);
return (NODE_TO_ELEM(lp, n));
}
void *
{
n = n->uln_next;
if (n == &lp->ul_null_node)
return (NULL);
return (NODE_TO_ELEM(lp, n));
}
void *
{
n = n->uln_prev;
if (n == &lp->ul_null_node)
return (NULL);
return (NODE_TO_ELEM(lp, n));
}
/*
* called from uu_lockup() and uu_release(), as part of our fork1()-safety.
*/
void
uu_list_lockup(void)
{
(void) pthread_mutex_lock(&uu_lpool_list_lock);
}
void
uu_list_release(void)
{
(void) pthread_mutex_unlock(&uu_lpool_list_lock);
}