diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2003-11-24 16:47:35 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2003-11-24 16:47:35 +0000 |
commit | 3cd8d3035fd3f38ad91973ecc8eaadabf80c2b02 (patch) | |
tree | 1c9a120fcdf17a4475692b93ef0acfb69ef0e05b /gnu | |
parent | 030d6d4b49be0b1feabb819f3efe4bbc713f2df8 (diff) |
Synch with gcc-3.3.2 version
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/lib/libiberty/include/dyn-string.h | 92 | ||||
-rw-r--r-- | gnu/lib/libiberty/include/hashtab.h | 103 | ||||
-rw-r--r-- | gnu/lib/libiberty/include/partition.h | 81 |
3 files changed, 276 insertions, 0 deletions
diff --git a/gnu/lib/libiberty/include/dyn-string.h b/gnu/lib/libiberty/include/dyn-string.h new file mode 100644 index 00000000000..67f7ab7d36e --- /dev/null +++ b/gnu/lib/libiberty/include/dyn-string.h @@ -0,0 +1,92 @@ +/* An abstract string datatype. + Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. + Contributed by Mark Mitchell (mark@markmitchell.com). + +This file is part of GNU CC. + +GNU CC 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 later version. + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +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 +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + + +typedef struct dyn_string +{ + int allocated; /* The amount of space allocated for the string. */ + int length; /* The actual length of the string. */ + char *s; /* The string itself, NUL-terminated. */ +}* dyn_string_t; + +/* The length STR, in bytes, not including the terminating NUL. */ +#define dyn_string_length(STR) \ + ((STR)->length) + +/* The NTBS in which the contents of STR are stored. */ +#define dyn_string_buf(STR) \ + ((STR)->s) + +/* Compare DS1 to DS2 with strcmp. */ +#define dyn_string_compare(DS1, DS2) \ + (strcmp ((DS1)->s, (DS2)->s)) + + +/* dyn_string functions are used in the demangling implementation + included in the G++ runtime library. To prevent collisions with + names in user programs, the functions that are used in the + demangler are given implementation-reserved names. */ + +#ifdef IN_LIBGCC2 + +#define dyn_string_init __cxa_dyn_string_init +#define dyn_string_new __cxa_dyn_string_new +#define dyn_string_delete __cxa_dyn_string_delete +#define dyn_string_release __cxa_dyn_string_release +#define dyn_string_resize __cxa_dyn_string_resize +#define dyn_string_clear __cxa_dyn_string_clear +#define dyn_string_copy __cxa_dyn_string_copy +#define dyn_string_copy_cstr __cxa_dyn_string_copy_cstr +#define dyn_string_prepend __cxa_dyn_string_prepend +#define dyn_string_prepend_cstr __cxa_dyn_string_prepend_cstr +#define dyn_string_insert __cxa_dyn_string_insert +#define dyn_string_insert_cstr __cxa_dyn_string_insert_cstr +#define dyn_string_insert_char __cxa_dyn_string_insert_char +#define dyn_string_append __cxa_dyn_string_append +#define dyn_string_append_cstr __cxa_dyn_string_append_cstr +#define dyn_string_append_char __cxa_dyn_string_append_char +#define dyn_string_substring __cxa_dyn_string_substring +#define dyn_string_eq __cxa_dyn_string_eq + +#endif /* IN_LIBGCC2 */ + + +extern int dyn_string_init PARAMS ((struct dyn_string *, int)); +extern dyn_string_t dyn_string_new PARAMS ((int)); +extern void dyn_string_delete PARAMS ((dyn_string_t)); +extern char *dyn_string_release PARAMS ((dyn_string_t)); +extern dyn_string_t dyn_string_resize PARAMS ((dyn_string_t, int)); +extern void dyn_string_clear PARAMS ((dyn_string_t)); +extern int dyn_string_copy PARAMS ((dyn_string_t, dyn_string_t)); +extern int dyn_string_copy_cstr PARAMS ((dyn_string_t, const char *)); +extern int dyn_string_prepend PARAMS ((dyn_string_t, dyn_string_t)); +extern int dyn_string_prepend_cstr PARAMS ((dyn_string_t, const char *)); +extern int dyn_string_insert PARAMS ((dyn_string_t, int, + dyn_string_t)); +extern int dyn_string_insert_cstr PARAMS ((dyn_string_t, int, + const char *)); +extern int dyn_string_insert_char PARAMS ((dyn_string_t, int, int)); +extern int dyn_string_append PARAMS ((dyn_string_t, dyn_string_t)); +extern int dyn_string_append_cstr PARAMS ((dyn_string_t, const char *)); +extern int dyn_string_append_char PARAMS ((dyn_string_t, int)); +extern int dyn_string_substring PARAMS ((dyn_string_t, + dyn_string_t, int, int)); +extern int dyn_string_eq PARAMS ((dyn_string_t, dyn_string_t)); diff --git a/gnu/lib/libiberty/include/hashtab.h b/gnu/lib/libiberty/include/hashtab.h new file mode 100644 index 00000000000..67c37a284f7 --- /dev/null +++ b/gnu/lib/libiberty/include/hashtab.h @@ -0,0 +1,103 @@ +/* An expandable hash tables datatype. + Copyright (C) 1999 Free Software Foundation, Inc. + Contributed by Vladimir Makarov (vmakarov@cygnus.com). + +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 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +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 +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* This package implements basic hash table functionality. It is possible + to search for an entry, create an entry and destroy an entry. + + Elements in the table are generic pointers. + + The size of the table is not fixed; if the occupancy of the table + grows too high the hash table will be expanded. + + The abstract data implementation is based on generalized Algorithm D + from Knuth's book "The art of computer programming". Hash table is + expanded by creation of new hash table and transferring elements from + the old table to the new table. */ + +#ifndef __HASHTAB_H__ +#define __HASHTAB_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <ansidecl.h> + +/* The hash table element is represented by the following type. */ + +typedef const void *hash_table_entry_t; + +/* Hash tables are of the following type. The structure + (implementation) of this type is not needed for using the hash + tables. All work with hash table should be executed only through + functions mentioned below. */ + +typedef struct +{ + /* Current size (in entries) of the hash table */ + size_t size; + /* Current number of elements including also deleted elements */ + size_t number_of_elements; + /* Current number of deleted elements in the table */ + size_t number_of_deleted_elements; + /* The following member is used for debugging. Its value is number + of all calls of `find_hash_table_entry' for the hash table. */ + int searches; + /* The following member is used for debugging. Its value is number + of collisions fixed for time of work with the hash table. */ + int collisions; + /* Pointer to function for evaluation of hash value (any unsigned value). + This function has one parameter of type hash_table_entry_t. */ + unsigned (*hash_function) PARAMS ((hash_table_entry_t)); + /* Pointer to function for test on equality of hash table elements (two + parameter of type hash_table_entry_t. */ + int (*eq_function) PARAMS ((hash_table_entry_t, hash_table_entry_t)); + /* Table itself */ + hash_table_entry_t *entries; +} *hash_table_t; + + +/* The prototypes of the package functions. */ + +extern hash_table_t create_hash_table + PARAMS ((size_t, unsigned (*) (hash_table_entry_t), + int (*) (hash_table_entry_t, hash_table_entry_t))); + +extern void delete_hash_table PARAMS ((hash_table_t)); + +extern void empty_hash_table PARAMS ((hash_table_t)); + +extern hash_table_entry_t *find_hash_table_entry + PARAMS ((hash_table_t, hash_table_entry_t, int)); + +extern void remove_element_from_hash_table_entry PARAMS ((hash_table_t, + hash_table_entry_t)); + +extern size_t hash_table_size PARAMS ((hash_table_t)); + +extern size_t hash_table_elements_number PARAMS ((hash_table_t)); + +extern int hash_table_collisions PARAMS ((hash_table_t)); + +extern int all_hash_table_collisions (); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __HASHTAB_H */ diff --git a/gnu/lib/libiberty/include/partition.h b/gnu/lib/libiberty/include/partition.h new file mode 100644 index 00000000000..f49d67a8cad --- /dev/null +++ b/gnu/lib/libiberty/include/partition.h @@ -0,0 +1,81 @@ +/* List implentation of a partition of consecutive integers. + Copyright (C) 2000 Free Software Foundation, Inc. + Contributed by CodeSourcery, LLC. + + This file is part of GNU CC. + + GNU CC 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 later version. + + GNU CC is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + 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 + along with GNU CC; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* This package implements a partition of consecutive integers. The + elements are partitioned into classes. Each class is represented + by one of its elements, the canonical element, which is chosen + arbitrarily from elements in the class. The principal operations + on a partition are FIND, which takes an element, determines its + class, and returns the canonical element for that class, and UNION, + which unites the two classes that contain two given elements into a + single class. + + The list implementation used here provides constant-time finds. By + storing the size of each class with the class's canonical element, + it is able to perform unions over all the classes in the partition + in O (N log N) time. */ + +#ifndef _PARTITION_H +#define _PARTITION_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <ansidecl.h> +#include <stdio.h> + +struct partition_elem +{ + /* The canonical element that represents the class containing this + element. */ + int class_element; + /* The next element in this class. Elements in each class form a + circular list. */ + struct partition_elem* next; + /* The number of elements in this class. Valid only if this is the + canonical element for its class. */ + unsigned class_count; +}; + +typedef struct partition_def +{ + /* The number of elements in this partition. */ + int num_elements; + /* The elements in the partition. */ + struct partition_elem elements[1]; +} *partition; + +extern partition partition_new PARAMS((int)); +extern void partition_delete PARAMS((partition)); +extern int partition_union PARAMS((partition, + int, + int)); +extern void partition_print PARAMS((partition, + FILE*)); + +/* Returns the canonical element corresponding to the class containing + ELEMENT__ in PARTITION__. */ + +#define partition_find(partition__, element__) \ + ((partition__)->elements[(element__)].class_element) + +#endif /* _PARTITION_H */ |