/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2013 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
*/
#include <mdb/mdb_debug.h>
#include <mdb/mdb_string.h>
#include <mdb/mdb_modapi.h>
#define NV_NAME(v) \
#define NV_SIZE(v) \
static size_t
{
size_t g, h = 0;
const char *p;
for (p = key; *p != '\0'; p++) {
h = (h << 4) + *p;
if ((g = (h & 0xf0000000)) != 0) {
h ^= (g >> 24);
h ^= g;
}
}
return (h);
}
static mdb_var_t *
{
mdb_var_t *v;
if (flags & MDB_NV_EXTNAME)
else
if (v == NULL)
return (NULL);
if (flags & MDB_NV_EXTNAME) {
v->v_lname[0] = '\0';
} else {
/*
* We don't overflow here since the mdb_var_t itself has
* room for the trailing \0.
*/
}
return (v);
}
static void
{
return;
if (v->v_flags & MDB_NV_OVERLOAD) {
}
}
}
/*
* Can return NULL only if the nv's memory allocation flags include UM_NOSLEEP
*/
mdb_nv_t *
{
return (NULL);
nv->nv_iter_bucket = 0;
return (nv);
}
void
{
mdb_var_t *v, *w;
size_t i;
return;
w = v->v_next;
}
}
}
{
mdb_var_t *v;
return (v);
}
return (NULL);
}
/*
* Interpose W in place of V. We replace V with W in nv_hash, and then
* set W's v_ndef overload chain to point at V.
*/
static mdb_var_t *
{
while (*pvp != v) {
}
*pvp = w;
w->v_ndef = v;
return (w);
}
/*
* Add W to the end of V's overload chain. We simply follow v_ndef to the
* end, and then append W. We don't expect these chains to grow very long.
*/
static mdb_var_t *
{
v = v->v_ndef;
v->v_ndef = w;
return (w);
}
/*
* Can return NULL only if the nv's memory allocation flags include UM_NOSLEEP
*/
{
mdb_var_t *v;
/*
* If the specified name is already hashed,
* and MDB_NV_OVERLOAD is set: insert new var into overload chain
* and MDB_NV_RDONLY is set: leave var unchanged, issue warning
* otherwise: update var with new value
*/
if (v->v_flags & MDB_NV_OVERLOAD) {
if (w == NULL) {
return (NULL);
}
if (flags & MDB_NV_INTERPOS)
v = nv_var_interpos(nv, i, v, w);
else
v = nv_var_overload(v, w);
} else if (v->v_flags & MDB_NV_RDONLY) {
if (!(flags & MDB_NV_SILENT)) {
warn("cannot modify read-only "
"variable '%s'\n", NV_NAME(v));
}
} else
return (v);
}
}
/*
* If the specified name was not found, initialize a new element
* and add it to the hash table at the beginning of this chain:
*/
if (v == NULL) {
return (NULL);
}
return (v);
}
static void
{
mdb_var_t *w = v;
v = v->v_ndef;
if (v == NULL) {
fail("var %p ('%s') not found on defn chain of %p\n",
}
}
void
{
return;
}
if (v != corpse) {
do {
nv->nv_um_flags);
return; /* No v_next changes needed */
} else
goto notfound;
}
break; /* Corpse is next on the chain */
if (v == NULL)
goto notfound;
} else
} else {
}
return;
fail("var %p ('%s') not found on hash chain: nv=%p [%lu]\n",
}
void
{
size_t i;
break;
}
nv->nv_iter_bucket = i;
}
{
size_t i;
if (v == NULL)
return (NULL);
return (v);
}
break;
}
nv->nv_iter_bucket = i;
return (v);
}
{
return (nv->nv_iter_elt);
}
{
}
static int
{
}
void
{
size_t i;
*vpp++ = v;
(int (*)(const void *, const void *))nv_compare);
break;
}
}
}
void
{
return;
break;
}
}
{
if (v->v_disc)
return (v->v_uvalue);
}
void
{
if (v->v_flags & MDB_NV_RDONLY) {
return;
}
if (v->v_disc)
else
v->v_uvalue = l;
}
void *
{
if (v->v_disc)
return (MDB_NV_COOKIE(v));
}
void
{
}
const char *
{
return (NV_NAME(v));
}
{
if (v->v_flags & MDB_NV_OVERLOAD)
return (v->v_ndef);
return (NULL);
}