ght.c 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Generic Hash Table Module
*/
#include <sys/sysmacros.h>
/*
* Revelations of the hash table and element structures.
*
* ght_t -> ght_impl_t *
* ghte_t -> ghte_impl_t *
*/
typedef struct ght_impl ght_impl_t;
typedef struct ghte_impl ghte_impl_t;
struct ghte_impl {
};
struct ght_impl {
char ghti_name[MAXNAMELEN];
};
static int i_ght_ctor(void *, void *, int);
static void i_ght_dtor(void *, void *);
#define GHT_LINKINFO "Generic Hash Table v%I%"
};
static struct modlinkage modlinkage = {
&modlmisc,
};
int
_init(void)
{
int err;
return (err);
return (0);
}
int
_fini(void)
{
int err;
return (err);
return (0);
}
int
{
}
/*
* Hash function for text string keys
*/
static uintptr_t
{
char *k = (char *)key;
hash = *k++;
while (*k != '\0') {
uint_t g;
if ((g = (hash & 0xf0000000)) == 0)
continue;
hash ^= (g >> 24) ^ g;
}
return (hash);
}
/*
* Comparitor for text string keys
*/
static int
{
}
/*
* Hash function for scalar keys
*/
static uintptr_t
{
}
/*
* Comparitor for scalar keys
*/
static int
{
}
/*
* Cache constructor for hash table entries
*/
/*ARGSUSED*/
static int
{
return (0);
}
/*
* Cache destructor for hash table entries
*/
static void
{
}
/*
* Create a hash table
*/
static int
{
int len;
return (EINVAL);
ghtip->ghti_entries = 0;
return (0);
}
/*
* External functions.
*/
/*
* Lock a table.
*/
void
{
}
/*
* Unlock a table.
*/
void
{
}
/*
* Create a string keyed table.
*/
int
{
int err;
i_ght_str_keycmp, &ghtip)) != 0)
return (err);
return (0);
}
/*
* Create a scalar keyed table.
*/
int
{
int err;
i_ght_scalar_keycmp, &ghtip)) != 0)
return (err);
return (0);
}
/*
* Destroy a table.
*/
int
{
if (ghtip->ghti_entries != 0)
return (EBUSY);
size = sizeof (ght_impl_t) +
return (0);
}
/*
* Return the number of entries in a table.
*/
{
return (ghtip->ghti_entries);
}
/*
* Allocate a new entry for a table.
*/
{
return (NULL);
}
/*
* Free a table entry (after it has been removed).
*/
void
{
}
/*
* Insert an entry into a table.
*/
int
{
ghte_impl_t **pp;
ghte_impl_t *p;
uint_t n;
pp = &(p->ghtei_next)) {
return (EEXIST);
}
ghteip->ghtei_next = p;
ghtip->ghti_entries++;
return (0);
}
/*
* Look-up an enrty in a table.
*/
int
{
ghte_impl_t *p;
uint_t n;
ASSERT(p->ghtei_active);
break;
}
if (p == NULL)
return (ENOENT);
return (0);
}
/*
* Increment the reference count on a hash table entry.
*/
void
{
}
/*
* Decrement the reference count on a hash table entry.
*/
void
{
}
/*
* Return the reference count on a hash table entry.
*/
{
}
/*
* Remove an entry from its table.
*/
void
{
ghte_impl_t **pp;
ghte_impl_t *p;
p = ghteip->ghtei_next;
*pp = p;
if (p != NULL) {
p->ghtei_prevp = pp;
}
--ghtip->ghti_entries;
}
/*
* Walk table entries calling fn() for each one.
*/
void
{
uint_t n;
ghte_impl_t *p;
for (n = 0; n < ghtip->ghti_nbuckets; n++) {
ASSERT(p->ghtei_active);
return;
}
}
}