OSDN Git Service

* cpplib.pot: Regenerate.
[pf3gnuchains/gcc-fork.git] / libcpp / include / symtab.h
index 8b79332..4107a6f 100644 (file)
@@ -1,9 +1,10 @@
 /* Hash tables.
 /* Hash tables.
-   Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2003, 2004, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
 
 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
 
 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
-Free Software Foundation; either version 2, or (at your option) any
+Free Software Foundation; either version 3, or (at your option) any
 later version.
 
 This program is distributed in the hope that it will be useful,
 later version.
 
 This program is distributed in the hope that it will be useful,
@@ -12,20 +13,23 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+along with this program; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 #ifndef LIBCPP_SYMTAB_H
 #define LIBCPP_SYMTAB_H
 
 #include "obstack.h"
 
 #ifndef LIBCPP_SYMTAB_H
 #define LIBCPP_SYMTAB_H
 
 #include "obstack.h"
+
+#ifndef GTY
 #define GTY(x) /* nothing */
 #define GTY(x) /* nothing */
+#endif
 
 /* This is what each hash table entry points to.  It may be embedded
    deeply within another object.  */
 typedef struct ht_identifier ht_identifier;
 
 /* This is what each hash table entry points to.  It may be embedded
    deeply within another object.  */
 typedef struct ht_identifier ht_identifier;
-struct ht_identifier GTY(())
-{
+typedef struct ht_identifier *ht_identifier_ptr;
+struct GTY(()) ht_identifier {
   const unsigned char *str;
   unsigned int len;
   unsigned int hash_value;
   const unsigned char *str;
   unsigned int len;
   unsigned int hash_value;
@@ -37,7 +41,7 @@ struct ht_identifier GTY(())
 typedef struct ht hash_table;
 typedef struct ht_identifier *hashnode;
 
 typedef struct ht hash_table;
 typedef struct ht_identifier *hashnode;
 
-enum ht_lookup_option {HT_NO_INSERT = 0, HT_ALLOC, HT_ALLOCED};
+enum ht_lookup_option {HT_NO_INSERT = 0, HT_ALLOC};
 
 /* An identifier hash table for cpplib and the front ends.  */
 struct ht
 
 /* An identifier hash table for cpplib and the front ends.  */
 struct ht
@@ -46,8 +50,11 @@ struct ht
   struct obstack stack;
 
   hashnode *entries;
   struct obstack stack;
 
   hashnode *entries;
-  /* Call back.  */
+  /* 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.  
+     NULL means use the usual allocator.  */
+  void * (*alloc_subobject) (size_t);
 
   unsigned int nslots;         /* Total slots in the entries array.  */
   unsigned int nelements;      /* Number of live elements.  */
 
   unsigned int nslots;         /* Total slots in the entries array.  */
   unsigned int nelements;      /* Number of live elements.  */
@@ -58,6 +65,9 @@ struct ht
   /* Table usage statistics.  */
   unsigned int searches;
   unsigned int collisions;
   /* Table usage statistics.  */
   unsigned int searches;
   unsigned int collisions;
+
+  /* Should 'entries' be freed when it is no longer needed?  */
+  bool entries_owned;
 };
 
 /* Initialize the hashtable with 2 ^ order entries.  */
 };
 
 /* Initialize the hashtable with 2 ^ order entries.  */
@@ -68,6 +78,11 @@ extern void ht_destroy (hash_table *);
 
 extern hashnode ht_lookup (hash_table *, const unsigned char *,
                           size_t, enum ht_lookup_option);
 
 extern hashnode ht_lookup (hash_table *, const unsigned char *,
                           size_t, enum ht_lookup_option);
+extern hashnode ht_lookup_with_hash (hash_table *, const unsigned char *,
+                                     size_t, unsigned int,
+                                     enum ht_lookup_option);
+#define HT_HASHSTEP(r, c) ((r) * 67 + ((c) - 113));
+#define HT_HASHFINISH(r, len) ((r) + (len))
 
 /* For all nodes in TABLE, make a callback.  The callback takes
    TABLE->PFILE, the node, and a PTR, and the callback sequence stops
 
 /* For all nodes in TABLE, make a callback.  The callback takes
    TABLE->PFILE, the node, and a PTR, and the callback sequence stops
@@ -75,6 +90,14 @@ extern hashnode ht_lookup (hash_table *, const unsigned char *,
 typedef int (*ht_cb) (struct cpp_reader *, hashnode, const void *);
 extern void ht_forall (hash_table *, ht_cb, const void *);
 
 typedef int (*ht_cb) (struct cpp_reader *, hashnode, const void *);
 extern void ht_forall (hash_table *, ht_cb, const void *);
 
+/* For all nodes in TABLE, call the callback.  If the callback returns
+   a nonzero value, the node is removed from the table.  */
+extern void ht_purge (hash_table *, ht_cb, const void *);
+
+/* Restore the hash table.  */
+extern void ht_load (hash_table *ht, hashnode *entries,
+                    unsigned int nslots, unsigned int nelements, bool own);
+
 /* Dump allocation statistics to stderr.  */
 extern void ht_dump_statistics (hash_table *);
 
 /* Dump allocation statistics to stderr.  */
 extern void ht_dump_statistics (hash_table *);