1203287Srnoland/************************************************************************** 2203287Srnoland * 3203287Srnoland * Copyright 2006 Tungsten Graphics, Inc., Bismack, ND. USA. 4203287Srnoland * All Rights Reserved. 5203287Srnoland * 6203287Srnoland * Permission is hereby granted, free of charge, to any person obtaining a 7203287Srnoland * copy of this software and associated documentation files (the 8203287Srnoland * "Software"), to deal in the Software without restriction, including 9203287Srnoland * without limitation the rights to use, copy, modify, merge, publish, 10203287Srnoland * distribute, sub license, and/or sell copies of the Software, and to 11203287Srnoland * permit persons to whom the Software is furnished to do so, subject to 12203287Srnoland * the following conditions: 13203287Srnoland * 14203287Srnoland * The above copyright notice and this permission notice (including the 15203287Srnoland * next paragraph) shall be included in all copies or substantial portions 16203287Srnoland * of the Software. 17203287Srnoland * 18203287Srnoland * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19203287Srnoland * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20203287Srnoland * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 21203287Srnoland * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 22203287Srnoland * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 23203287Srnoland * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 24203287Srnoland * USE OR OTHER DEALINGS IN THE SOFTWARE. 25203287Srnoland * 26203287Srnoland * 27203287Srnoland **************************************************************************/ 28203287Srnoland 29203287Srnoland#include <sys/cdefs.h> 30203287Srnoland__FBSDID("$FreeBSD: releng/10.3/sys/dev/drm/drm_hashtab.h 203287 2010-01-31 14:25:29Z rnoland $"); 31203287Srnoland 32203287Srnoland/* 33203287Srnoland * Simple open hash tab implementation. 34203287Srnoland * 35203287Srnoland * Authors: 36203287Srnoland * Thomas Hellstr��m <thomas-at-tungstengraphics-dot-com> 37203287Srnoland */ 38203287Srnoland 39203287Srnoland#ifndef DRM_HASHTAB_H 40203287Srnoland#define DRM_HASHTAB_H 41203287Srnoland 42203287Srnoland#define drm_hash_entry(_ptr, _type, _member) container_of(_ptr, _type, _member) 43203287Srnoland 44203287Srnolandstruct drm_hash_item { 45203287Srnoland LIST_ENTRY(drm_hash_item) head; 46203287Srnoland unsigned long key; 47203287Srnoland}; 48203287Srnoland 49203287Srnolandstruct drm_open_hash { 50203287Srnoland LIST_HEAD(drm_hash_item_list, drm_hash_item) *table; 51203287Srnoland unsigned int size; 52203287Srnoland unsigned int order; 53203287Srnoland unsigned long mask; 54203287Srnoland}; 55203287Srnoland 56203287Srnolandextern int drm_ht_create(struct drm_open_hash *ht, unsigned int order); 57203287Srnolandextern int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item); 58203287Srnolandextern int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item, 59203287Srnoland unsigned long seed, int bits, int shift, 60203287Srnoland unsigned long add); 61203287Srnolandextern int drm_ht_find_item(struct drm_open_hash *ht, unsigned long key, struct drm_hash_item **item); 62203287Srnoland 63203287Srnolandextern void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key); 64203287Srnolandextern int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key); 65203287Srnolandextern int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item); 66203287Srnolandextern void drm_ht_remove(struct drm_open_hash *ht); 67203287Srnoland 68203287Srnoland#endif 69