182657471SMarkus Pfeiffer /** 282657471SMarkus Pfeiffer * Copyright (c) 2013 Larisa Grigore<larisagrigore@gmail.com>. 382657471SMarkus Pfeiffer * All rights reserved. 482657471SMarkus Pfeiffer * 582657471SMarkus Pfeiffer * Redistribution and use in source and binary forms, with or without 682657471SMarkus Pfeiffer * modification, are permitted provided that the following conditions 782657471SMarkus Pfeiffer * are met: 882657471SMarkus Pfeiffer * 1. Redistributions of source code must retain the above copyright 982657471SMarkus Pfeiffer * notice, this list of conditions and the following disclaimer. 1082657471SMarkus Pfeiffer * 2. Redistributions in binary form must reproduce the above copyright 1182657471SMarkus Pfeiffer * notice, this list of conditions and the following disclaimer in the 1282657471SMarkus Pfeiffer * documentation and/or other materials provided with the distribution. 1382657471SMarkus Pfeiffer * 3. The name of the author may not be used to endorse or promote products 1482657471SMarkus Pfeiffer * derived from this software without specific prior written permission. 1582657471SMarkus Pfeiffer * 1682657471SMarkus Pfeiffer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1782657471SMarkus Pfeiffer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1882657471SMarkus Pfeiffer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1982657471SMarkus Pfeiffer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2082657471SMarkus Pfeiffer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2182657471SMarkus Pfeiffer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2282657471SMarkus Pfeiffer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2382657471SMarkus Pfeiffer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2482657471SMarkus Pfeiffer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2582657471SMarkus Pfeiffer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2682657471SMarkus Pfeiffer */ 2782657471SMarkus Pfeiffer 28*ff86f401SSascha Wildner #ifndef _SYSVIPC_HASH_H_ 29*ff86f401SSascha Wildner #define _SYSVIPC_HASH_H_ 30*ff86f401SSascha Wildner 3182657471SMarkus Pfeiffer #include <sys/queue.h> 3282657471SMarkus Pfeiffer 3382657471SMarkus Pfeiffer struct hashentry { 3482657471SMarkus Pfeiffer u_long key; 3582657471SMarkus Pfeiffer void * value; 3682657471SMarkus Pfeiffer LIST_ENTRY(hashentry) entry_link; 3782657471SMarkus Pfeiffer }; 3882657471SMarkus Pfeiffer 3982657471SMarkus Pfeiffer LIST_HEAD(entries_list, hashentry); 4082657471SMarkus Pfeiffer 4182657471SMarkus Pfeiffer struct hashtable { 4282657471SMarkus Pfeiffer int nr_elems; 4382657471SMarkus Pfeiffer struct entries_list *entries; 4482657471SMarkus Pfeiffer }; 4582657471SMarkus Pfeiffer 4682657471SMarkus Pfeiffer struct hashtable *_hash_init(int); 4782657471SMarkus Pfeiffer int _hash_destroy(struct hashtable *); 4882657471SMarkus Pfeiffer void _hash_insert(struct hashtable *, u_long, void *); 4982657471SMarkus Pfeiffer void *_hash_lookup(struct hashtable *, u_long); 5082657471SMarkus Pfeiffer void *_hash_remove(struct hashtable *, u_long); 5182657471SMarkus Pfeiffer int get_hash_size(int); 52*ff86f401SSascha Wildner 53*ff86f401SSascha Wildner #endif /* !_SYSVIPC_HASH_H_ */ 54