hash.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"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <synch.h>
#include <memory.h>
#include <getxby_door.h>
static int hash_string();
hash_t *
int size;
{
sizeof (hash_entry_t *)*size);
return (ptr);
}
hash_t *
int size;
{
(sizeof (hash_entry_t *) * size));
sizeof (hash_entry_t *)*size);
return (ptr);
}
char **
{
int bucket;
} else {
}
}
}
} else {
}
}
}
/*
* not found....
* insert new entry into bucket...
*/
/*
* hook into chain from tbl...
*/
/*
* hook into bucket chain
*/
}
char **
{
}
}
} else {
}
}
}
return (NULL);
}
char *
{
/*
* del_this points to entry marked for deletion, prev to
* item preceeding in bucket chain or NULL if del_this is first.
* remove from bucket chain first....
*/
}
} else {
}
/*
* now remove from tbl chain....
*/
} else {
}
}
}
int
{
int c = 0;
while (tmp) {
c++;
}
return (c);
}
int
{
int c = 0;
while (tmp) {
c++;
}
return (c);
}
void
{
while (tmp) {
if (ptr) {
}
}
}
}
static int
hash_string(char *s, int modulo)
{
unsigned result = 0;
int i = 1;
while (*s != 0) {
result += (*s++ << i++);
}
}
int
int howlong)
{
/*
* We don't want to spend too much time reaping nor too little.
* We cap the TTL at 2^28 to prevent overflow. This is 8.5 years,
* so we aren't really going to reap anything anyway.
* Also, we want the total time to be one second more than the
* time to expire the entries.
*/
howlong++;
/* Total_buckets can range from 37 to 2^30 */
/*
* In the realm of buckets_per_second. total_buckets might
* be near 2^30, so we divide first
*/
seconds_per_interval = 4;
} else if (total_buckets >= howlong) {
/* Still buckets per second, but it is safe to multiply first */
seconds_per_interval = 4;
/*
* total_buckets, so we are safe to use this as the interval.
* Figure out the rounding error and sleep it at the end.
*/
buckets_per_interval = 1;
} else {
/*
* is too short. Use 8 as the minimum, then adjust the extra
* at the end. We need 8 because of rounding error.
*/
buckets_per_interval = 8;
}
/*
* bucket keeps track of which bucket in the whole table we are on.
* buckets_togo is which bucket in this interval we are on.
*/
for (bucket = buckets_togo = 0;
bucket++) {
if (buckets_togo <= 0) {
}
count++;
ST_UPDATE_PENDING) == 0) &&
< now)) {
count++;
admin_ptr->nsc_entries--;
} else {
}
}
buckets_togo--;
}
return (count);
}