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 | ec5bb3116786c5d4fff565e52e3e138d6c8739f6 (patch) | |
tree | fc12376314b50972f5ef2291d9c2dfb4ed39c217 | |
parent | 3cd8d3035fd3f38ad91973ecc8eaadabf80c2b02 (diff) |
OpenBSD changes: synch somewhere between binutils-2.10 and 2.11
Support for mkstemps in choose-temp.
-rw-r--r-- | gnu/lib/libiberty/include/demangle.h | 16 | ||||
-rw-r--r-- | gnu/lib/libiberty/include/libiberty.h | 38 | ||||
-rw-r--r-- | gnu/lib/libiberty/include/obstack.h | 18 | ||||
-rw-r--r-- | gnu/lib/libiberty/include/splay-tree.h | 9 | ||||
-rw-r--r-- | gnu/lib/libiberty/include/symcat.h | 4 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/choose-temp.c | 3 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/configure | 2 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/configure.bat | 14 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/cplus-dem.c | 393 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/dyn-string.c | 24 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/hashtab.c | 450 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/makefile.dos | 29 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/pexecute.c | 4 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/strerror.c | 4 |
14 files changed, 475 insertions, 533 deletions
diff --git a/gnu/lib/libiberty/include/demangle.h b/gnu/lib/libiberty/include/demangle.h index 63fe5e2adf4..a6234119aff 100644 --- a/gnu/lib/libiberty/include/demangle.h +++ b/gnu/lib/libiberty/include/demangle.h @@ -78,6 +78,16 @@ extern enum demangling_styles #define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP) #define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG) +/* Provide information about the available demangle styles. This code is + pulled from gdb into libiberty because it is useful to binutils also. */ + +extern struct demangler_engine +{ + const char *demangling_style_name; + enum demangling_styles demangling_style; + const char *demangling_style_doc; +} libiberty_demanglers[]; + extern char * cplus_demangle PARAMS ((const char *mangled, int options)); @@ -92,4 +102,10 @@ cplus_mangle_opname PARAMS ((const char *opname, int options)); extern void set_cplus_marker_for_demangling PARAMS ((int ch)); +extern enum demangling_styles +cplus_demangle_set_style PARAMS ((enum demangling_styles style)); + +extern enum demangling_styles +cplus_demangle_name_to_style PARAMS ((const char *name)); + #endif /* DEMANGLE_H */ diff --git a/gnu/lib/libiberty/include/libiberty.h b/gnu/lib/libiberty/include/libiberty.h index cf313662ef4..05114a27b6c 100644 --- a/gnu/lib/libiberty/include/libiberty.h +++ b/gnu/lib/libiberty/include/libiberty.h @@ -51,14 +51,23 @@ extern char *concat PARAMS ((const char *, ...)); extern int fdmatch PARAMS ((int fd1, int fd2)); +/* Get the working directory. The result is cached, so don't call + chdir() between calls to getpwd(). */ + +extern char * getpwd PARAMS ((void)); + /* Get the amount of time the process has run, in microseconds. */ extern long get_run_time PARAMS ((void)); -/* Choose a temporary directory to use for scratch files. */ +/* Choose a temporary directory to use for scratch files, DEPRECATED */ extern char *choose_temp_base PARAMS ((void)); +/* Return a temporary file name or NULL if unable to create one. */ + +extern char *make_temp_file PARAMS ((const char *)); + /* Allocate memory filled with spaces. Allocates using malloc. */ extern const char *spaces PARAMS ((int count)); @@ -108,11 +117,7 @@ extern int xatexit PARAMS ((void (*fn) (void))); /* Exit, calling all the functions registered with xatexit. */ -#ifndef __GNUC__ extern void xexit PARAMS ((int status)); -#else -void xexit PARAMS ((int status)) __attribute__ ((noreturn)); -#endif /* Set the program name used by xmalloc. */ @@ -125,13 +130,14 @@ extern void xmalloc_set_program_name PARAMS ((const char *)); #ifdef ANSI_PROTOTYPES /* Get a definition for size_t. */ #include <stddef.h> +/* Get a definition for va_list. */ +#include <stdarg.h> #endif extern PTR xmalloc PARAMS ((size_t)); -/* Reallocate memory without fail. This works like xmalloc. - - FIXME: We do not declare the parameter types for the same reason as - xmalloc. */ +/* Reallocate memory without fail. This works like xmalloc. Note, + realloc type functions are not suitable for attribute malloc since + they may return the same address across multiple calls. */ extern PTR xrealloc PARAMS ((PTR, size_t)); @@ -144,6 +150,10 @@ extern PTR xcalloc PARAMS ((size_t, size_t)); extern char *xstrdup PARAMS ((const char *)); +/* Copy an existing memory buffer to a new memory buffer without fail. */ + +extern PTR xmemdup PARAMS ((const PTR, size_t, size_t)); + /* hex character manipulation routines */ #define _hex_array_size 256 @@ -172,6 +182,16 @@ extern int pexecute PARAMS ((const char *, char * const *, const char *, extern int pwait PARAMS ((int, int *, int)); +/* Like sprintf but provides a pointer to malloc'd storage, which must + be freed by the caller. */ + +extern int asprintf PARAMS ((char **, const char *, ...)); + +/* Like vsprintf but provides a pointer to malloc'd storage, which + must be freed by the caller. */ + +extern int vasprintf PARAMS ((char **, const char *, va_list)); + #ifdef __cplusplus } #endif diff --git a/gnu/lib/libiberty/include/obstack.h b/gnu/lib/libiberty/include/obstack.h index 38e96777660..a20ab55967a 100644 --- a/gnu/lib/libiberty/include/obstack.h +++ b/gnu/lib/libiberty/include/obstack.h @@ -143,12 +143,16 @@ extern "C" { #if defined _LIBC || defined HAVE_STRING_H # include <string.h> -# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) +# if defined __STDC__ && __STDC__ +# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) +# else +# define _obstack_memcpy(To, From, N) memcpy ((To), (char *)(From), (N)) +# endif #else # ifdef memcpy -# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) +# define _obstack_memcpy(To, From, N) memcpy ((To), (char *)(From), (N)) # else -# define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N)) +# define _obstack_memcpy(To, From, N) bcopy ((char *)(From), (To), (N)) # endif #endif @@ -385,7 +389,7 @@ __extension__ \ int __len = (length); \ if (__o->next_free + __len > __o->chunk_limit) \ _obstack_newchunk (__o, __len); \ - _obstack_memcpy (__o->next_free, (char *) (where), __len); \ + _obstack_memcpy (__o->next_free, (where), __len); \ __o->next_free += __len; \ (void) 0; }) @@ -395,7 +399,7 @@ __extension__ \ int __len = (length); \ if (__o->next_free + __len + 1 > __o->chunk_limit) \ _obstack_newchunk (__o, __len + 1); \ - _obstack_memcpy (__o->next_free, (char *) (where), __len); \ + _obstack_memcpy (__o->next_free, (where), __len); \ __o->next_free += __len; \ *(__o->next_free)++ = 0; \ (void) 0; }) @@ -510,14 +514,14 @@ __extension__ \ ( (h)->temp = (length), \ (((h)->next_free + (h)->temp > (h)->chunk_limit) \ ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ - _obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \ + _obstack_memcpy ((h)->next_free, (where), (h)->temp), \ (h)->next_free += (h)->temp) # define obstack_grow0(h,where,length) \ ( (h)->temp = (length), \ (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ - _obstack_memcpy ((h)->next_free, (char *) (where), (h)->temp), \ + _obstack_memcpy ((h)->next_free, (where), (h)->temp), \ (h)->next_free += (h)->temp, \ *((h)->next_free)++ = 0) diff --git a/gnu/lib/libiberty/include/splay-tree.h b/gnu/lib/libiberty/include/splay-tree.h index e828fe7e907..6d70c8d9075 100644 --- a/gnu/lib/libiberty/include/splay-tree.h +++ b/gnu/lib/libiberty/include/splay-tree.h @@ -44,7 +44,7 @@ typedef unsigned long int splay_tree_key; typedef unsigned long int splay_tree_value; /* Forward declaration for a node in the tree. */ -typedef struct splay_tree_node *splay_tree_node; +typedef struct splay_tree_node_s *splay_tree_node; /* The type of a function which compares two splay-tree keys. The function should return values as for qsort. */ @@ -62,7 +62,7 @@ typedef void (*splay_tree_delete_value_fn) PARAMS((splay_tree_value)); typedef int (*splay_tree_foreach_fn) PARAMS((splay_tree_node, void*)); /* The nodes in the splay tree. */ -struct splay_tree_node +struct splay_tree_node_s { /* The key. */ splay_tree_key key; @@ -76,7 +76,7 @@ struct splay_tree_node }; /* The splay tree itself. */ -typedef struct splay_tree +typedef struct splay_tree_s { /* The root of the tree. */ splay_tree_node root; @@ -95,7 +95,8 @@ extern splay_tree splay_tree_new PARAMS((splay_tree_compare_fn, splay_tree_delete_key_fn, splay_tree_delete_value_fn)); extern void splay_tree_delete PARAMS((splay_tree)); -extern void splay_tree_insert PARAMS((splay_tree, +extern splay_tree_node splay_tree_insert + PARAMS((splay_tree, splay_tree_key, splay_tree_value)); extern splay_tree_node splay_tree_lookup diff --git a/gnu/lib/libiberty/include/symcat.h b/gnu/lib/libiberty/include/symcat.h index 01efada2618..3e27162b264 100644 --- a/gnu/lib/libiberty/include/symcat.h +++ b/gnu/lib/libiberty/include/symcat.h @@ -1,6 +1,6 @@ /* Symbol concatenation utilities. - Copyright (C) 1998, Free Software Foundation, Inc. + Copyright (C) 1998, 2000 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 @@ -28,7 +28,7 @@ #define CONCAT2(a,b) a/**/b #define CONCAT3(a,b,c) a/**/b/**/c #define CONCAT4(a,b,c,d) a/**/b/**/c/**/d -#define STRINGX(s) "?" +#define STRINGX(s) "s" #endif #define XCONCAT2(a,b) CONCAT2(a,b) diff --git a/gnu/lib/libiberty/src/choose-temp.c b/gnu/lib/libiberty/src/choose-temp.c index 826d818ed62..3babdcda511 100644 --- a/gnu/lib/libiberty/src/choose-temp.c +++ b/gnu/lib/libiberty/src/choose-temp.c @@ -91,6 +91,7 @@ try (dir, base) return 0; } +#if defined(__MSDOS__) && !defined(__GO32__) /* Return a prefix for temporary file names or NULL if unable to find one. The current directory is chosen if all else fails so the program is exited if a temporary directory can't be found (mktemp fails). @@ -140,6 +141,8 @@ choose_temp_base () abort (); return temp_filename; } +#endif + /* Return a temporary file name (as a string) or NULL if unable to create one. */ diff --git a/gnu/lib/libiberty/src/configure b/gnu/lib/libiberty/src/configure index 02c826d929e..e387788250f 100644 --- a/gnu/lib/libiberty/src/configure +++ b/gnu/lib/libiberty/src/configure @@ -561,7 +561,7 @@ else libiberty_topdir="${srcdir}/.." fi ac_aux_dir= -for ac_dir in $libiberty_topdir $srcdir/$libiberty_topdir; do +for ac_dir in ${GNUSYSTEM_AUX_DIR} $libiberty_topdir $srcdir/$libiberty_topdir; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" diff --git a/gnu/lib/libiberty/src/configure.bat b/gnu/lib/libiberty/src/configure.bat new file mode 100644 index 00000000000..18881ac2f75 --- /dev/null +++ b/gnu/lib/libiberty/src/configure.bat @@ -0,0 +1,14 @@ +@echo off
+if "%1" == "h8/300" goto h8300
+
+echo Configuring libiberty for go32
+copy Makefile.dos Makefile
+echo #define NEED_sys_siglist 1 >> config.h
+echo #define NEED_psignal 1 >> config.h
+goto exit
+
+:h8300
+echo Configuring libiberty for H8/300
+copy Makefile.dos Makefile
+
+:exit
diff --git a/gnu/lib/libiberty/src/cplus-dem.c b/gnu/lib/libiberty/src/cplus-dem.c index 52249d2b580..ff6625244df 100644 --- a/gnu/lib/libiberty/src/cplus-dem.c +++ b/gnu/lib/libiberty/src/cplus-dem.c @@ -53,12 +53,6 @@ char * realloc (); #define min(X,Y) (((X) < (Y)) ? (X) : (Y)) -/* A value at least one greater than the maximum number of characters - that will be output when using the `%d' format with `printf'. */ -#define INTBUF_SIZE 32 - -extern void fancy_abort PARAMS ((void)) ATTRIBUTE_NORETURN; - static const char *mystrstr PARAMS ((const char *, const char *)); static const char * @@ -252,6 +246,49 @@ typedef enum type_kind_t tk_real } type_kind_t; +struct demangler_engine libiberty_demanglers[] = +{ + { + AUTO_DEMANGLING_STYLE_STRING, + auto_demangling, + "Automatic selection based on executable" + } + , + { + GNU_DEMANGLING_STYLE_STRING, + gnu_demangling, + "GNU (g++) style demangling" + } + , + { + LUCID_DEMANGLING_STYLE_STRING, + lucid_demangling, + "Lucid (lcc) style demangling" + } + , + { + ARM_DEMANGLING_STYLE_STRING, + arm_demangling, + "ARM style demangling" + } + , + { + HP_DEMANGLING_STYLE_STRING, + hp_demangling, + "HP (aCC) style demangling" + } + , + { + EDG_DEMANGLING_STYLE_STRING, + edg_demangling, + "EDG style demangling" + } + , + { + NULL, unknown_demangling, NULL + } +}; + #define STRING_EMPTY(str) ((str) -> b == (str) -> p) #define PREPEND_BLANK(str) {if (!STRING_EMPTY(str)) \ string_prepend(str, " ");} @@ -351,9 +388,6 @@ string_prepend PARAMS ((string *, const char *)); static void string_prependn PARAMS ((string *, const char *, int)); -static void -string_append_template_idx PARAMS ((string *, int)); - static int get_count PARAMS ((const char **, int *)); @@ -431,25 +465,6 @@ qualifier_string PARAMS ((int)); static const char* demangle_qualifier PARAMS ((int)); -static int -demangle_expression PARAMS ((struct work_stuff *, const char **, string *, - type_kind_t)); - -static int -demangle_integral_value PARAMS ((struct work_stuff *, const char **, - string *)); - -static int -demangle_real_value PARAMS ((struct work_stuff *, const char **, string *)); - -static void -demangle_arm_hp_template PARAMS ((struct work_stuff *, const char **, int, - string *)); - -static void -recursively_demangle PARAMS ((struct work_stuff *, const char **, string *, - int)); - /* Translate count to integer, consuming tokens in the process. Conversion terminates on the first non-digit character. @@ -758,6 +773,40 @@ cplus_mangle_opname (opname, options) return (0); } +/* Add a routine to set the demangling style to be sure it is valid and + allow for any demangler initialization that maybe necessary. */ + +enum demangling_styles +cplus_demangle_set_style (style) + enum demangling_styles style; +{ + struct demangler_engine *demangler = libiberty_demanglers; + + for (; demangler->demangling_style != unknown_demangling; ++demangler) + if (style == demangler->demangling_style) + { + current_demangling_style = style; + return current_demangling_style; + } + + return unknown_demangling; +} + +/* Do string name to style translation */ + +enum demangling_styles +cplus_demangle_name_to_style (name) + const char *name; +{ + struct demangler_engine *demangler = libiberty_demanglers; + + for (; demangler->demangling_style != unknown_demangling; ++demangler) + if (strcmp (name, demangler->demangling_style_name) == 0) + return demangler->demangling_style; + + return unknown_demangling; +} + /* char *cplus_demangle (const char *mangled, int options) If MANGLED is a mangled function name produced by GNU C++, then @@ -1356,155 +1405,87 @@ demangle_template_template_parm (work, mangled, tname) } static int -demangle_expression (work, mangled, s, tk) +demangle_integral_value (work, mangled, s) struct work_stuff *work; const char** mangled; string* s; - type_kind_t tk; { - int need_operator = 0; int success; - success = 1; - string_appendn (s, "(", 1); - (*mangled)++; - while (success && **mangled != 'W' && **mangled != '\0') + if (**mangled == 'E') { - if (need_operator) - { - size_t i; - size_t len; + int need_operator = 0; - success = 0; + success = 1; + string_appendn (s, "(", 1); + (*mangled)++; + while (success && **mangled != 'W' && **mangled != '\0') + { + if (need_operator) + { + size_t i; + size_t len; - len = strlen (*mangled); + success = 0; - for (i = 0; - i < sizeof (optable) / sizeof (optable [0]); - ++i) - { - size_t l = strlen (optable[i].in); + len = strlen (*mangled); - if (l <= len - && memcmp (optable[i].in, *mangled, l) == 0) + for (i = 0; + i < sizeof (optable) / sizeof (optable [0]); + ++i) { - string_appendn (s, " ", 1); - string_append (s, optable[i].out); - string_appendn (s, " ", 1); - success = 1; - (*mangled) += l; - break; + size_t l = strlen (optable[i].in); + + if (l <= len + && memcmp (optable[i].in, *mangled, l) == 0) + { + string_appendn (s, " ", 1); + string_append (s, optable[i].out); + string_appendn (s, " ", 1); + success = 1; + (*mangled) += l; + break; + } } + + if (!success) + break; } + else + need_operator = 1; - if (!success) - break; + success = demangle_template_value_parm (work, mangled, s, + tk_integral); } - else - need_operator = 1; - success = demangle_template_value_parm (work, mangled, s, tk); - } - - if (**mangled != 'W') - success = 0; - else - { - string_appendn (s, ")", 1); - (*mangled)++; + if (**mangled != 'W') + success = 0; + else + { + string_appendn (s, ")", 1); + (*mangled)++; + } } - - return success; -} - -static int -demangle_integral_value (work, mangled, s) - struct work_stuff *work; - const char** mangled; - string* s; -{ - int success; - - if (**mangled == 'E') - success = demangle_expression (work, mangled, s, tk_integral); else if (**mangled == 'Q' || **mangled == 'K') success = demangle_qualified (work, mangled, s, 0, 1); else { - int value; - success = 0; - /* Negative numbers are indicated with a leading `m'. */ if (**mangled == 'm') { string_appendn (s, "-", 1); (*mangled)++; } - - /* Read the rest of the number. */ - value = consume_count_with_underscores (mangled); - if (value != -1) - { - char buf[INTBUF_SIZE]; - sprintf (buf, "%d", value); - string_append (s, buf); - - /* If the next character is an underscore, skip it. */ - if (**mangled == '_') - (*mangled)++; - - /* All is well. */ - success = 1; - } - } - - return success; -} - -/* Demangle the real value in MANGLED. */ - -static int -demangle_real_value (work, mangled, s) - struct work_stuff *work; - const char **mangled; - string* s; -{ - if (**mangled == 'E') - return demangle_expression (work, mangled, s, tk_real); - - if (**mangled == 'm') - { - string_appendn (s, "-", 1); - (*mangled)++; - } - while (isdigit ((unsigned char)**mangled)) - { - string_appendn (s, *mangled, 1); - (*mangled)++; - } - if (**mangled == '.') /* fraction */ - { - string_appendn (s, ".", 1); - (*mangled)++; - while (isdigit ((unsigned char)**mangled)) - { - string_appendn (s, *mangled, 1); - (*mangled)++; - } - } - if (**mangled == 'e') /* exponent */ - { - string_appendn (s, "e", 1); - (*mangled)++; while (isdigit ((unsigned char)**mangled)) { string_appendn (s, *mangled, 1); (*mangled)++; + success = 1; } } - return 1; + return success; } static int @@ -1530,7 +1511,11 @@ demangle_template_value_parm (work, mangled, s, tk) if (work->tmpl_argvec) string_append (s, work->tmpl_argvec[idx]); else - string_append_template_idx (s, idx); + { + char buf[10]; + sprintf(buf, "T%d", idx); + string_append (s, buf); + } } else if (tk == tk_integral) success = demangle_integral_value (work, mangled, s); @@ -1566,7 +1551,38 @@ demangle_template_value_parm (work, mangled, s, tk) success = 0; } else if (tk == tk_real) - success = demangle_real_value (work, mangled, s); + { + if (**mangled == 'm') + { + string_appendn (s, "-", 1); + (*mangled)++; + } + while (isdigit ((unsigned char)**mangled)) + { + string_appendn (s, *mangled, 1); + (*mangled)++; + } + if (**mangled == '.') /* fraction */ + { + string_appendn (s, ".", 1); + (*mangled)++; + while (isdigit ((unsigned char)**mangled)) + { + string_appendn (s, *mangled, 1); + (*mangled)++; + } + } + if (**mangled == 'e') /* exponent */ + { + string_appendn (s, "e", 1); + (*mangled)++; + while (isdigit ((unsigned char)**mangled)) + { + string_appendn (s, *mangled, 1); + (*mangled)++; + } + } + } else if (tk == tk_pointer || tk == tk_reference) { if (**mangled == 'Q') @@ -1664,9 +1680,11 @@ demangle_template (work, mangled, tname, trawname, is_type, remember) } else { - string_append_template_idx (tname, idx); + char buf[10]; + sprintf(buf, "T%d", idx); + string_append (tname, buf); if (trawname) - string_append_template_idx (trawname, idx); + string_append (trawname, buf); } } else @@ -2507,7 +2525,7 @@ gnu_special (work, mangled, declp) break; default: n = consume_count (mangled); - if (n < 0 || n > (long) strlen (*mangled)) + if (n < 0 || n > strlen (*mangled)) { success = 0; break; @@ -2674,7 +2692,7 @@ arm_special (mangled, declp) { n = consume_count (mangled); if (n == -1 - || n > (long) strlen (*mangled)) + || n > strlen (*mangled)) return 0; string_prependn (declp, *mangled, n); (*mangled) += n; @@ -2735,6 +2753,7 @@ demangle_qualified (work, mangled, result, isfuncname, append) { int qualifiers = 0; int success = 1; + const char *p; char num[2]; string temp; string last_name; @@ -2766,10 +2785,19 @@ demangle_qualified (work, mangled, result, isfuncname, append) /* GNU mangled name with more than 9 classes. The count is preceded by an underscore (to distinguish it from the <= 9 case) and followed by an underscore. */ - (*mangled)++; - qualifiers = consume_count_with_underscores (mangled); - if (qualifiers == -1) + p = *mangled + 2; + qualifiers = atoi (p); + if (!isdigit ((unsigned char)*p) || *p == '0') + success = 0; + + /* Skip the digits. */ + while (isdigit ((unsigned char)*p)) + ++p; + + if (*p != '_') success = 0; + + *mangled = p + 1; break; case '1': @@ -2960,7 +2988,9 @@ get_count (type, count) int n; if (!isdigit ((unsigned char)**type)) - return (0); + { + return (0); + } else { *count = **type - '0'; @@ -3099,12 +3129,7 @@ do_type (work, mangled, result) (*mangled)++; string_append (&decl, ")"); - - /* We don't need to prepend `::' for a qualified name; - demangle_qualified will do that for us. */ - if (**mangled != 'Q') - string_prepend (&decl, SCOPE_STRING (work)); - + string_prepend (&decl, SCOPE_STRING (work)); if (isdigit ((unsigned char)**mangled)) { n = consume_count (mangled); @@ -3137,14 +3162,6 @@ do_type (work, mangled, result) else break; } - else if (**mangled == 'Q') - { - success = demangle_qualified (work, mangled, &decl, - /*isfuncnam=*/0, - /*append=*/0); - if (!success) - break; - } else { success = 0; @@ -3257,7 +3274,11 @@ do_type (work, mangled, result) if (work->tmpl_argvec) string_append (result, work->tmpl_argvec[idx]); else - string_append_template_idx (result, idx); + { + char buf[10]; + sprintf(buf, "T%d", idx); + string_append (result, buf); + } success = 1; } @@ -3437,7 +3458,7 @@ demangle_fund_type (work, mangled, result) int i; (*mangled)++; for (i = 0; - i < (long) sizeof (buf) - 1 && **mangled && **mangled != '_'; + i < sizeof (buf) - 1 && **mangled && **mangled != '_'; (*mangled)++, i++) buf[i] = **mangled; if (**mangled != '_') @@ -3506,7 +3527,7 @@ demangle_fund_type (work, mangled, result) static int do_hpacc_template_const_value (work, mangled, result) - struct work_stuff *work ATTRIBUTE_UNUSED; + struct work_stuff *work; const char **mangled; string *result; { @@ -4376,16 +4397,6 @@ string_prependn (p, s, n) } } -static void -string_append_template_idx (s, idx) - string *s; - int idx; -{ - char buf[INTBUF_SIZE + 1 /* 'T' */]; - sprintf(buf, "T%d", idx); - string_append (s, buf); -} - /* To generate a standalone demangler program for testing purposes, just compile and link this file with -DMAIN and libiberty.a. When run, it demangles each command line arg, or each stdin string, and @@ -4395,13 +4406,13 @@ string_append_template_idx (s, idx) #include "getopt.h" -static const char *program_name; -static const char *program_version = VERSION; +static char *program_name; +static char *program_version = VERSION; static int flags = DMGL_PARAMS | DMGL_ANSI; static void demangle_it PARAMS ((char *)); -static void usage PARAMS ((FILE *, int)) ATTRIBUTE_NORETURN; -static void fatal PARAMS ((const char *)) ATTRIBUTE_NORETURN; +static void usage PARAMS ((FILE *, int)); +static void fatal PARAMS ((char *)); static void demangle_it (mangled_name) @@ -4462,12 +4473,6 @@ fancy_abort () } -static const char * -standard_symbol_characters PARAMS ((void)); - -static const char * -hp_symbol_characters PARAMS ((void)); - /* Return the string of non-alnum characters that may occur as a valid symbol component, in the standard assembler symbol syntax. */ @@ -4516,8 +4521,6 @@ hp_symbol_characters () } -extern int main PARAMS ((int, char **)); - int main (argc, argv) int argc; @@ -4525,7 +4528,7 @@ main (argc, argv) { char *result; int c; - const char *valid_symbols; + char *valid_symbols; program_name = argv[0]; @@ -4545,7 +4548,7 @@ main (argc, argv) break; case 'v': printf ("GNU %s (C++ demangler), version %s\n", program_name, program_version); - return (0); + exit (0); case '_': strip_underscore = 1; break; @@ -4577,7 +4580,7 @@ main (argc, argv) { fprintf (stderr, "%s: unknown demangling style `%s'\n", program_name, optarg); - return (1); + exit (1); } break; } @@ -4655,12 +4658,12 @@ main (argc, argv) } } - return (0); + exit (0); } static void fatal (str) - const char *str; + char *str; { fprintf (stderr, "%s: %s\n", program_name, str); exit (1); diff --git a/gnu/lib/libiberty/src/dyn-string.c b/gnu/lib/libiberty/src/dyn-string.c index 34f88ade96d..69897f84c5e 100644 --- a/gnu/lib/libiberty/src/dyn-string.c +++ b/gnu/lib/libiberty/src/dyn-string.c @@ -305,30 +305,6 @@ dyn_string_insert_cstr (dest, pos, src) return 1; } -/* Inserts character C into DEST starting at position POS. DEST is - expanded as necessary. Returns 1 on success. On failure, - RETURN_ON_ALLOCATION_FAILURE, deletes DEST and returns 0. */ - -int -dyn_string_insert_char (dest, pos, c) - dyn_string_t dest; - int pos; - int c; -{ - int i; - - if (dyn_string_resize (dest, dest->length + 1) == NULL) - return 0; - /* Make room for the insertion. Be sure to copy the NUL. */ - for (i = dest->length; i >= pos; --i) - dest->s[i + 1] = dest->s[i]; - /* Add the new character. */ - dest->s[pos] = c; - /* Compute the new length. */ - ++dest->length; - return 1; -} - /* Append S to DS, resizing DS if necessary. Returns 1 on success. On failure, if RETURN_ON_ALLOCATION_FAILURE, deletes DEST and returns 0. */ diff --git a/gnu/lib/libiberty/src/hashtab.c b/gnu/lib/libiberty/src/hashtab.c index 16c5d3e4b12..c59e3159520 100644 --- a/gnu/lib/libiberty/src/hashtab.c +++ b/gnu/lib/libiberty/src/hashtab.c @@ -35,20 +35,34 @@ Boston, MA 02111-1307, USA. */ #include "config.h" #endif -#include <sys/types.h> - #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif -#include <stdio.h> - #include "libiberty.h" #include "hashtab.h" +#ifdef HASHTAB_STATS +/* The following variable is used for debugging. Its value is number + of all calls of `find_hash_table_entry' for all hash tables. */ + +static int all_searches = 0; + +/* The following variable is used for debugging. Its value is number + of collisions fixed for time of work with all hash tables. */ + +static int all_collisions = 0; + +/* The following variable is used for debugging. Its value is number + of all table expansions fixed for time of work with all hash + tables. */ + +static int all_expansions = 0; +#endif + /* This macro defines reserved value for empty table entry. */ -#define EMPTY_ENTRY ((void *) 0) +#define EMPTY_ENTRY NULL /* This macro defines reserved value for table entry which contained a deleted element. */ @@ -59,27 +73,19 @@ Boston, MA 02111-1307, USA. */ greater than given source number. */ static unsigned long -higher_prime_number (n) - unsigned long n; +higher_prime_number (number) + unsigned long number; { unsigned long i; - n |= 0x01; /* Force N to be odd. */ - if (n < 9) - return n; /* All odd numbers < 9 are prime. */ - - next: - n += 2; - i = 3; - do + for (number = (number / 2) * 2 + 3;; number += 2) { - if (n % i == 0) - goto next; - i += 2; + for (i = 3; i * i <= number; i += 2) + if (number % i == 0) + break; + if (i * i > number) + return number; } - while ((i * i) <= n); - - return n; } /* This function creates table with length slightly longer than given @@ -87,22 +93,26 @@ higher_prime_number (n) hash table entries are EMPTY_ENTRY). The function returns the created hash table. */ -htab_t -htab_create (size, hash_f, eq_f, del_f) +hash_table_t +create_hash_table (size, hash_function, eq_function) size_t size; - htab_hash hash_f; - htab_eq eq_f; - htab_del del_f; + unsigned (*hash_function) PARAMS ((hash_table_entry_t)); + int (*eq_function) PARAMS ((hash_table_entry_t, hash_table_entry_t)); { - htab_t result; + hash_table_t result; size = higher_prime_number (size); - result = (htab_t) xcalloc (1, sizeof (struct htab)); - result->entries = (void **) xcalloc (size, sizeof (void *)); + result = (hash_table_t) xmalloc (sizeof (*result)); + result->entries + = (hash_table_entry_t *) xmalloc (size * sizeof (hash_table_entry_t)); result->size = size; - result->hash_f = hash_f; - result->eq_f = eq_f; - result->del_f = del_f; + result->hash_function = hash_function; + result->eq_function = eq_function; +#ifdef HASHTAB_STATS + result->searches = 0; + result->collisions = 0; +#endif + empty_hash_table (result); return result; } @@ -110,18 +120,9 @@ htab_create (size, hash_f, eq_f, del_f) Naturally the hash table must already exist. */ void -htab_delete (htab) - htab_t htab; +delete_hash_table (htab) + hash_table_t htab; { - int i; - if (htab->del_f) - for (i = htab->size - 1; i >= 0; i--) - { - if (htab->entries[i] != EMPTY_ENTRY - && htab->entries[i] != DELETED_ENTRY) - (*htab->del_f) (htab->entries[i]); - } - free (htab->entries); free (htab); } @@ -129,49 +130,12 @@ htab_delete (htab) /* This function clears all entries in the given hash table. */ void -htab_empty (htab) - htab_t htab; +empty_hash_table (htab) + hash_table_t htab; { - int i; - if (htab->del_f) - for (i = htab->size - 1; i >= 0; i--) - { - if (htab->entries[i] != EMPTY_ENTRY - && htab->entries[i] != DELETED_ENTRY) - (*htab->del_f) (htab->entries[i]); - } - - memset (htab->entries, 0, htab->size * sizeof (void *)); -} - -/* Similar to htab_find_slot, but without several unwanted side effects: - - Does not call htab->eq_f when it finds an existing entry. - - Does not change the count of elements/searches/collisions in the - hash table. - This function also assumes there are no deleted entries in the table. - HASH is the hash value for the element to be inserted. */ -static void ** -find_empty_slot_for_expand (htab, hash) - htab_t htab; - unsigned int hash; -{ - size_t size = htab->size; - unsigned int hash2 = 1 + hash % (size - 2); - unsigned int index = hash % size; - - for (;;) - { - void **slot = htab->entries + index; - if (*slot == EMPTY_ENTRY) - return slot; - - if (*slot == DELETED_ENTRY) - abort (); - - index += hash2; - if (index >= size) - index -= size; - } + memset (htab->entries, 0, htab->size * sizeof (hash_table_entry_t)); + htab->number_of_elements = 0; + htab->number_of_deleted_elements = 0; } /* The following function changes size of memory allocated for the @@ -181,224 +145,120 @@ find_empty_slot_for_expand (htab, hash) table entries is changed. */ static void -htab_expand (htab) - htab_t htab; +expand_hash_table (htab) + hash_table_t htab; { - void **oentries; - void **olimit; - void **p; - - oentries = htab->entries; - olimit = oentries + htab->size; - - htab->size = higher_prime_number (htab->size * 2); - htab->entries = xcalloc (htab->size, sizeof (void **)); - - htab->n_elements -= htab->n_deleted; - htab->n_deleted = 0; - - p = oentries; - do - { - void *x = *p; - if (x != EMPTY_ENTRY && x != DELETED_ENTRY) - { - void **q = find_empty_slot_for_expand (htab, (*htab->hash_f) (x)); - *q = x; - } - p++; - } - while (p < olimit); - free (oentries); + hash_table_t new_htab; + hash_table_entry_t *entry_ptr; + hash_table_entry_t *new_entry_ptr; + + new_htab = create_hash_table (htab->number_of_elements * 2, + htab->hash_function, htab->eq_function); + for (entry_ptr = htab->entries; entry_ptr < htab->entries + htab->size; + entry_ptr++) + if (*entry_ptr != EMPTY_ENTRY && *entry_ptr != DELETED_ENTRY) + { + new_entry_ptr = find_hash_table_entry (new_htab, *entry_ptr, 1); + *new_entry_ptr = (*entry_ptr); + } + free (htab->entries); + *htab = (*new_htab); + free (new_htab); } -/* This function searches for a hash table entry equal to the given - element. It cannot be used to insert or delete an element. */ - -void * -htab_find_with_hash (htab, element, hash) - htab_t htab; - const void *element; - unsigned int hash; +/* This function searches for hash table entry which contains element + equal to given value or empty entry in which given value can be + placed (if the element with given value does not exist in the + table). The function works in two regimes. The first regime is + used only for search. The second is used for search and + reservation empty entry for given value. The table is expanded if + occupancy (taking into accout also deleted elements) is more than + 75%. Naturally the hash table must already exist. If reservation + flag is TRUE then the element with given value should be inserted + into the table entry before another call of + `find_hash_table_entry'. */ + +hash_table_entry_t * +find_hash_table_entry (htab, element, reserve) + hash_table_t htab; + hash_table_entry_t element; + int reserve; { - unsigned int index, hash2; - size_t size; - - htab->searches++; - size = htab->size; - hash2 = 1 + hash % (size - 2); - index = hash % size; + hash_table_entry_t *entry_ptr; + hash_table_entry_t *first_deleted_entry_ptr; + unsigned index, hash_value, secondary_hash_value; - for (;;) + if (htab->size * 3 <= htab->number_of_elements * 4) { - void *entry = htab->entries[index]; - if (entry == EMPTY_ENTRY) - return NULL; - else if (entry != DELETED_ENTRY && (*htab->eq_f) (entry, element)) - return entry; - - htab->collisions++; - index += hash2; - if (index >= size) - index -= size; +#ifdef HASHTAB_STATS + all_expansions++; +#endif + expand_hash_table (htab); } -} - -/* Like htab_find_slot_with_hash, but compute the hash value from the - element. */ -void * -htab_find (htab, element) - htab_t htab; - const void *element; -{ - return htab_find_with_hash (htab, element, (*htab->hash_f) (element)); -} - -/* This function searches for a hash table slot containing an entry - equal to the given element. To delete an entry, call this with - INSERT = 0, then call htab_clear_slot on the slot returned (possibly - after doing some checks). To insert an entry, call this with - INSERT = 1, then write the value you want into the returned slot. */ - -void ** -htab_find_slot_with_hash (htab, element, hash, insert) - htab_t htab; - const void *element; - unsigned int hash; - int insert; -{ - void **first_deleted_slot; - unsigned int index, hash2; - size_t size; - - if (insert && htab->size * 3 <= htab->n_elements * 4) - htab_expand (htab); - - size = htab->size; - hash2 = 1 + hash % (size - 2); - index = hash % size; - + hash_value = (*htab->hash_function) (element); + secondary_hash_value = 1 + hash_value % (htab->size - 2); + index = hash_value % htab->size; +#ifdef HASHTAB_STATS htab->searches++; - first_deleted_slot = NULL; - + all_searches++; +#endif + first_deleted_entry_ptr = NULL; +#ifdef HASHTAB_STATS + for (;;htab->collisions++, all_collisions++) +#else for (;;) +#endif { - void *entry = htab->entries[index]; - if (entry == EMPTY_ENTRY) - { - if (!insert) - return NULL; - - htab->n_elements++; - - if (first_deleted_slot) + entry_ptr = htab->entries + index; + if (*entry_ptr == EMPTY_ENTRY) + { + if (reserve) { - *first_deleted_slot = EMPTY_ENTRY; - return first_deleted_slot; + htab->number_of_elements++; + if (first_deleted_entry_ptr != NULL) + { + entry_ptr = first_deleted_entry_ptr; + *entry_ptr = DELETED_ENTRY; + } } - - return &htab->entries[index]; - } - - if (entry == DELETED_ENTRY) - { - if (!first_deleted_slot) - first_deleted_slot = &htab->entries[index]; - } - else - { - if ((*htab->eq_f) (entry, element)) - return &htab->entries[index]; - } - - htab->collisions++; - index += hash2; - if (index >= size) - index -= size; + break; + } + else if (*entry_ptr != DELETED_ENTRY) + { + if ((*htab->eq_function) (*entry_ptr, element)) + break; + } + else if (first_deleted_entry_ptr == NULL) + first_deleted_entry_ptr = entry_ptr; + index += secondary_hash_value; + if (index >= htab->size) + index -= htab->size; } + return entry_ptr; } -/* Like htab_find_slot_with_hash, but compute the hash value from the - element. */ -void ** -htab_find_slot (htab, element, insert) - htab_t htab; - const void *element; - int insert; -{ - return htab_find_slot_with_hash (htab, element, (*htab->hash_f) (element), - insert); -} - -/* This function deletes an element with the given value from hash - table. If there is no matching element in the hash table, this - function does nothing. */ +/* This function deletes element with given value from hash table. + The hash table entry value will be `DELETED_ENTRY' after the + function call. Naturally the hash table must already exist. Hash + table entry for given value should be not empty (or deleted). */ void -htab_remove_elt (htab, element) - htab_t htab; - void *element; +remove_element_from_hash_table_entry (htab, element) + hash_table_t htab; + hash_table_entry_t element; { - void **slot; - - slot = htab_find_slot (htab, element, 0); - if (*slot == EMPTY_ENTRY) - return; + hash_table_entry_t *entry_ptr; - if (htab->del_f) - (*htab->del_f) (*slot); - - *slot = DELETED_ENTRY; - htab->n_deleted++; -} - -/* This function clears a specified slot in a hash table. It is - useful when you've already done the lookup and don't want to do it - again. */ - -void -htab_clear_slot (htab, slot) - htab_t htab; - void **slot; -{ - if (slot < htab->entries || slot >= htab->entries + htab->size - || *slot == EMPTY_ENTRY || *slot == DELETED_ENTRY) - abort (); - if (htab->del_f) - (*htab->del_f) (*slot); - *slot = DELETED_ENTRY; - htab->n_deleted++; -} - -/* This function scans over the entire hash table calling - CALLBACK for each live entry. If CALLBACK returns false, - the iteration stops. INFO is passed as CALLBACK's second - argument. */ - -void -htab_traverse (htab, callback, info) - htab_t htab; - htab_trav callback; - void *info; -{ - void **slot, **limit; - slot = htab->entries; - limit = slot + htab->size; - do - { - void *x = *slot; - if (x != EMPTY_ENTRY && x != DELETED_ENTRY) - if (!(*callback) (slot, info)) - break; - } - while (++slot < limit); + entry_ptr = find_hash_table_entry (htab, element, 0); + *entry_ptr = DELETED_ENTRY; + htab->number_of_deleted_elements++; } /* The following function returns current size of given hash table. */ size_t -htab_size (htab) - htab_t htab; +hash_table_size (htab) + hash_table_t htab; { return htab->size; } @@ -407,23 +267,39 @@ htab_size (htab) hash table. */ size_t -htab_elements (htab) - htab_t htab; +hash_table_elements_number (htab) + hash_table_t htab; { - return htab->n_elements - htab->n_deleted; + return htab->number_of_elements - htab->number_of_deleted_elements; } +#ifdef HASHTAB_STATS /* The following function returns number of percents of fixed collisions during all work with given hash table. */ -double -htab_collisions (htab) - htab_t htab; +int +hash_table_collisions (htab) + hash_table_t htab; { int searches; searches = htab->searches; if (searches == 0) - return 0.0; - return (double)htab->collisions / (double)searches; + searches++; + return htab->collisions * 100 / searches; +} + +/* The following function returns number of percents of fixed + collisions during all work with all hash tables. */ + +int +all_hash_table_collisions () +{ + int searches; + + searches = all_searches; + if (searches == 0) + searches++; + return all_collisions * 100 / searches; } +#endif diff --git a/gnu/lib/libiberty/src/makefile.dos b/gnu/lib/libiberty/src/makefile.dos new file mode 100644 index 00000000000..7eba62c3395 --- /dev/null +++ b/gnu/lib/libiberty/src/makefile.dos @@ -0,0 +1,29 @@ +CFLAGS=-O2 + +OBJS = \ + argv.o \ + basename.o \ + concat.o \ + cplus-dem.o \ + fdmatch.o \ + floatformat.o \ + getopt.o \ + getopt1.o \ + getruntime.o \ + hex.o \ + msdos.o \ + obstack.o \ + spaces.o \ + strerror.o \ + strsignal.o \ + xatexit.o \ + xexit.o \ + xmalloc.o \ + $E + +.c.o: + gcc -I../include $(CFLAGS) -c $< + +libiberty.a : $(OBJS) + -rm libiberty.a + ar rvs libiberty.a $(OBJS) diff --git a/gnu/lib/libiberty/src/pexecute.c b/gnu/lib/libiberty/src/pexecute.c index 56ddec78dd8..5003f1fe4d5 100644 --- a/gnu/lib/libiberty/src/pexecute.c +++ b/gnu/lib/libiberty/src/pexecute.c @@ -656,7 +656,7 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) const char *program; char * const *argv; const char *this_pname; - const char *temp_base ATTRIBUTE_UNUSED; + const char *temp_base; char **errmsg_fmt, **errmsg_arg; int flags; { @@ -763,7 +763,7 @@ int pwait (pid, status, flags) int pid; int *status; - int flags ATTRIBUTE_UNUSED; + int flags; { /* ??? Here's an opportunity to canonicalize the values in STATUS. Needed? */ diff --git a/gnu/lib/libiberty/src/strerror.c b/gnu/lib/libiberty/src/strerror.c index 644cc75462a..ae7e29bfa89 100644 --- a/gnu/lib/libiberty/src/strerror.c +++ b/gnu/lib/libiberty/src/strerror.c @@ -656,7 +656,7 @@ strerror (errnoval) else if ((sys_errlist == NULL) || (sys_errlist[errnoval] == NULL)) { /* In range, but no sys_errlist or no entry at this index. */ - sprintf (buf, "Error %d", errnoval); + snprintf (buf, sizeof buf, "Error %d", errnoval); msg = buf; } else @@ -727,7 +727,7 @@ strerrno (errnoval) else if ((error_names == NULL) || (error_names[errnoval] == NULL)) { /* In range, but no error_names or no entry at this index. */ - sprintf (buf, "Error %d", errnoval); + snprintf (buf, sizeof buf, "Error %d", errnoval); name = (const char *) buf; } else |