Blame lib/dynamicsizehash.h

Packit 032894
/* Copyright (C) 2000-2010 Red Hat, Inc.
Packit 032894
   This file is part of elfutils.
Packit 032894
   Written by Ulrich Drepper <drepper@redhat.com>, 2000.
Packit 032894
Packit 032894
   This file is free software; you can redistribute it and/or modify
Packit 032894
   it under the terms of either
Packit 032894
Packit 032894
     * the GNU Lesser General Public License as published by the Free
Packit 032894
       Software Foundation; either version 3 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or
Packit 032894
Packit 032894
     * the GNU General Public License as published by the Free
Packit 032894
       Software Foundation; either version 2 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or both in parallel, as here.
Packit 032894
Packit 032894
   elfutils is distributed in the hope that it will be useful, but
Packit 032894
   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 032894
   General Public License for more details.
Packit 032894
Packit 032894
   You should have received copies of the GNU General Public License and
Packit 032894
   the GNU Lesser General Public License along with this program.  If
Packit 032894
   not, see <http://www.gnu.org/licenses/>.  */
Packit 032894
Packit 032894
#include <stddef.h>
Packit 032894
Packit 032894
/* Before including this file the following macros must be defined:
Packit 032894
Packit 032894
   NAME      name of the hash table structure.
Packit 032894
   TYPE      data type of the hash table entries
Packit 032894
Packit 032894
   The following macros if present select features:
Packit 032894
Packit 032894
   ITERATE   iterating over the table entries is possible
Packit 032894
   HASHTYPE  integer type for hash values, default unsigned long int
Packit 032894
 */
Packit 032894
Packit 032894
Packit 032894
/* Optionally include an entry pointing to the first used entry.  */
Packit 032894
#ifdef ITERATE
Packit 032894
# define FIRST(name)	name##_ent *first;
Packit 032894
# define NEXT(name)	struct name##_ent *next;
Packit 032894
#else
Packit 032894
# define FIRST(name)
Packit 032894
# define NEXT(name)
Packit 032894
#endif
Packit 032894
Packit 032894
#ifndef HASHTYPE
Packit 032894
# define HASHTYPE unsigned long int
Packit 032894
#endif
Packit 032894
Packit 032894
Packit 032894
/* Defined separately.  */
Packit 032894
extern size_t next_prime (size_t seed);
Packit 032894
Packit 032894
Packit 032894
/* Table entry type.  */
Packit 032894
#define _DYNHASHENTTYPE(name) \
Packit 032894
  typedef struct name##_ent						      \
Packit 032894
  {									      \
Packit 032894
    HASHTYPE hashval;							      \
Packit 032894
    TYPE data;								      \
Packit 032894
    NEXT (name)								      \
Packit 032894
  } name##_ent
Packit 032894
#define DYNHASHENTTYPE(name) _DYNHASHENTTYPE (name)
Packit 032894
DYNHASHENTTYPE (NAME);
Packit 032894
Packit 032894
Packit 032894
/* Type of the dynamic hash table data structure.  */
Packit 032894
#define _DYNHASHTYPE(name) \
Packit 032894
typedef struct								      \
Packit 032894
{									      \
Packit 032894
  size_t size;								      \
Packit 032894
  size_t filled;							      \
Packit 032894
  name##_ent *table;							      \
Packit 032894
  FIRST	(name)								      \
Packit 032894
} name
Packit 032894
#define DYNHASHTYPE(name) _DYNHASHTYPE (name)
Packit 032894
DYNHASHTYPE (NAME);
Packit 032894
Packit 032894
Packit 032894
Packit 032894
#define _FUNCTIONS(name) \
Packit 032894
/* Initialize the hash table.  */					      \
Packit 032894
extern int name##_init (name *htab, size_t init_size);			      \
Packit 032894
									      \
Packit 032894
/* Free resources allocated for hash table.  */				      \
Packit 032894
extern int name##_free (name *htab);					      \
Packit 032894
									      \
Packit 032894
/* Insert new entry.  */						      \
Packit 032894
extern int name##_insert (name *htab, HASHTYPE hval, TYPE data);	      \
Packit 032894
									      \
Packit 032894
/* Insert new entry, possibly overwrite old entry.  */			      \
Packit 032894
extern int name##_overwrite (name *htab, HASHTYPE hval, TYPE data);	      \
Packit 032894
									      \
Packit 032894
/* Find entry in hash table.  */					      \
Packit 032894
extern TYPE name##_find (name *htab, HASHTYPE hval, TYPE val);
Packit 032894
#define FUNCTIONS(name) _FUNCTIONS (name)
Packit 032894
FUNCTIONS (NAME)
Packit 032894
Packit 032894
Packit 032894
#ifdef ITERATE
Packit 032894
# define _XFUNCTIONS(name) \
Packit 032894
/* Get next element in table.  */					      \
Packit 032894
extern TYPE name##_iterate (name *htab, void **ptr);
Packit 032894
# define XFUNCTIONS(name) _XFUNCTIONS (name)
Packit 032894
XFUNCTIONS (NAME)
Packit 032894
#endif
Packit 032894
Packit 032894
#ifndef NO_UNDEF
Packit 032894
# undef DYNHASHENTTYPE
Packit 032894
# undef DYNHASHTYPE
Packit 032894
# undef FUNCTIONS
Packit 032894
# undef _FUNCTIONS
Packit 032894
# undef XFUNCTIONS
Packit 032894
# undef _XFUNCTIONS
Packit 032894
# undef NAME
Packit 032894
# undef TYPE
Packit 032894
# undef ITERATE
Packit 032894
# undef COMPARE
Packit 032894
# undef FIRST
Packit 032894
# undef NEXT
Packit 032894
#endif