1178525Sjb/* 2178525Sjb * CDDL HEADER START 3178525Sjb * 4178525Sjb * The contents of this file are subject to the terms of the 5178525Sjb * Common Development and Distribution License, Version 1.0 only 6178525Sjb * (the "License"). You may not use this file except in compliance 7178525Sjb * with the License. 8178525Sjb * 9178525Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10178525Sjb * or http://www.opensolaris.org/os/licensing. 11178525Sjb * See the License for the specific language governing permissions 12178525Sjb * and limitations under the License. 13178525Sjb * 14178525Sjb * When distributing Covered Code, include this CDDL HEADER in each 15178525Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16178525Sjb * If applicable, add the following below this CDDL HEADER, with the 17178525Sjb * fields enclosed by brackets "[]" replaced with your own identifying 18178525Sjb * information: Portions Copyright [yyyy] [name of copyright owner] 19178525Sjb * 20178525Sjb * CDDL HEADER END 21178525Sjb */ 22178525Sjb/* 23178525Sjb * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24178525Sjb * Use is subject to license terms. 25178525Sjb */ 26178525Sjb 27178525Sjb#pragma ident "%Z%%M% %I% %E% SMI" 28178525Sjb 29178525Sjb#include <sys/types.h> 30178538Sjb#include <sgs.h> 31178525Sjb 32178525Sjb/* 33178525Sjb * function that will find a prime'ish number. Usefull for 34178525Sjb * hashbuckets and related things. 35178525Sjb */ 36178525Sjbuint_t 37178525Sjbfindprime(uint_t count) 38178525Sjb{ 39178525Sjb uint_t h, f; 40178525Sjb 41178525Sjb if (count <= 3) 42178525Sjb return (3); 43178525Sjb 44178525Sjb 45178525Sjb /* 46178525Sjb * Check to see if divisible by two, if so 47178525Sjb * increment. 48178525Sjb */ 49178525Sjb if ((count & 0x1) == 0) 50178525Sjb count++; 51178525Sjb 52178525Sjb for (h = count, f = 2; f * f <= h; f++) 53178525Sjb if ((h % f) == 0) 54178525Sjb h += f = 1; 55178525Sjb return (h); 56178525Sjb} 57