OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc4/] [libcpp/] [include/] [symtab.h] - Diff between revs 270 and 519

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 270 Rev 519
/* Hash tables.
/* Hash tables.
   Copyright (C) 2000, 2001, 2003, 2004, 2007, 2008, 2009
   Copyright (C) 2000, 2001, 2003, 2004, 2007, 2008, 2009
   Free Software Foundation, Inc.
   Free Software Foundation, Inc.
 
 
This program is free software; you can redistribute it and/or modify it
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
Free Software Foundation; either version 3, or (at your option) any
later version.
later version.
 
 
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING3.  If not see
along with this program; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */
<http://www.gnu.org/licenses/>.  */
 
 
#ifndef LIBCPP_SYMTAB_H
#ifndef LIBCPP_SYMTAB_H
#define LIBCPP_SYMTAB_H
#define LIBCPP_SYMTAB_H
 
 
#include "obstack.h"
#include "obstack.h"
 
 
#ifndef GTY
#ifndef GTY
#define GTY(x) /* nothing */
#define GTY(x) /* nothing */
#endif
#endif
 
 
/* This is what each hash table entry points to.  It may be embedded
/* This is what each hash table entry points to.  It may be embedded
   deeply within another object.  */
   deeply within another object.  */
typedef struct ht_identifier ht_identifier;
typedef struct ht_identifier ht_identifier;
struct GTY(()) ht_identifier {
struct GTY(()) ht_identifier {
  const unsigned char *str;
  const unsigned char *str;
  unsigned int len;
  unsigned int len;
  unsigned int hash_value;
  unsigned int hash_value;
};
};
 
 
#define HT_LEN(NODE) ((NODE)->len)
#define HT_LEN(NODE) ((NODE)->len)
#define HT_STR(NODE) ((NODE)->str)
#define HT_STR(NODE) ((NODE)->str)
 
 
typedef struct ht hash_table;
typedef struct ht hash_table;
typedef struct ht_identifier *hashnode;
typedef struct ht_identifier *hashnode;
 
 
enum ht_lookup_option {HT_NO_INSERT = 0, HT_ALLOC};
enum ht_lookup_option {HT_NO_INSERT = 0, HT_ALLOC};
 
 
/* An identifier hash table for cpplib and the front ends.  */
/* An identifier hash table for cpplib and the front ends.  */
struct ht
struct ht
{
{
  /* Identifiers are allocated from here.  */
  /* Identifiers are allocated from here.  */
  struct obstack stack;
  struct obstack stack;
 
 
  hashnode *entries;
  hashnode *entries;
  /* Call back, allocate a node.  */
  /* Call back, allocate a node.  */
  hashnode (*alloc_node) (hash_table *);
  hashnode (*alloc_node) (hash_table *);
  /* Call back, allocate something that hangs off a node like a cpp_macro.
  /* Call back, allocate something that hangs off a node like a cpp_macro.
     NULL means use the usual allocator.  */
     NULL means use the usual allocator.  */
  void * (*alloc_subobject) (size_t);
  void * (*alloc_subobject) (size_t);
 
 
  unsigned int nslots;          /* Total slots in the entries array.  */
  unsigned int nslots;          /* Total slots in the entries array.  */
  unsigned int nelements;       /* Number of live elements.  */
  unsigned int nelements;       /* Number of live elements.  */
 
 
  /* Link to reader, if any.  For the benefit of cpplib.  */
  /* Link to reader, if any.  For the benefit of cpplib.  */
  struct cpp_reader *pfile;
  struct cpp_reader *pfile;
 
 
  /* Table usage statistics.  */
  /* Table usage statistics.  */
  unsigned int searches;
  unsigned int searches;
  unsigned int collisions;
  unsigned int collisions;
 
 
  /* Should 'entries' be freed when it is no longer needed?  */
  /* Should 'entries' be freed when it is no longer needed?  */
  bool entries_owned;
  bool entries_owned;
};
};
 
 
/* Initialize the hashtable with 2 ^ order entries.  */
/* Initialize the hashtable with 2 ^ order entries.  */
extern hash_table *ht_create (unsigned int order);
extern hash_table *ht_create (unsigned int order);
 
 
/* Frees all memory associated with a hash table.  */
/* Frees all memory associated with a hash table.  */
extern void ht_destroy (hash_table *);
extern void ht_destroy (hash_table *);
 
 
extern hashnode ht_lookup (hash_table *, const unsigned char *,
extern hashnode ht_lookup (hash_table *, const unsigned char *,
                           size_t, enum ht_lookup_option);
                           size_t, enum ht_lookup_option);
extern hashnode ht_lookup_with_hash (hash_table *, const unsigned char *,
extern hashnode ht_lookup_with_hash (hash_table *, const unsigned char *,
                                     size_t, unsigned int,
                                     size_t, unsigned int,
                                     enum ht_lookup_option);
                                     enum ht_lookup_option);
#define HT_HASHSTEP(r, c) ((r) * 67 + ((c) - 113));
#define HT_HASHSTEP(r, c) ((r) * 67 + ((c) - 113));
#define HT_HASHFINISH(r, len) ((r) + (len))
#define HT_HASHFINISH(r, len) ((r) + (len))
 
 
/* For all nodes in TABLE, make a callback.  The callback takes
/* For all nodes in TABLE, make a callback.  The callback takes
   TABLE->PFILE, the node, and a PTR, and the callback sequence stops
   TABLE->PFILE, the node, and a PTR, and the callback sequence stops
   if the callback returns zero.  */
   if the callback returns zero.  */
typedef int (*ht_cb) (struct cpp_reader *, hashnode, const void *);
typedef int (*ht_cb) (struct cpp_reader *, hashnode, const void *);
extern void ht_forall (hash_table *, ht_cb, const void *);
extern void ht_forall (hash_table *, ht_cb, const void *);
 
 
/* For all nodes in TABLE, call the callback.  If the callback returns
/* For all nodes in TABLE, call the callback.  If the callback returns
   a nonzero value, the node is removed from the table.  */
   a nonzero value, the node is removed from the table.  */
extern void ht_purge (hash_table *, ht_cb, const void *);
extern void ht_purge (hash_table *, ht_cb, const void *);
 
 
/* Restore the hash table.  */
/* Restore the hash table.  */
extern void ht_load (hash_table *ht, hashnode *entries,
extern void ht_load (hash_table *ht, hashnode *entries,
                     unsigned int nslots, unsigned int nelements, bool own);
                     unsigned int nslots, unsigned int nelements, bool own);
 
 
/* Dump allocation statistics to stderr.  */
/* Dump allocation statistics to stderr.  */
extern void ht_dump_statistics (hash_table *);
extern void ht_dump_statistics (hash_table *);
 
 
#endif /* LIBCPP_SYMTAB_H */
#endif /* LIBCPP_SYMTAB_H */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.