From: Bernd Edlinger Date: Mon, 28 May 2018 18:21:23 +0000 (+0000) Subject: splay-tree.h (splay_tree_compare_strings, [...]): Declare new utility functions. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b0c31bc65b510881ebf481493e1127105bc74ee9;p=gcc.git splay-tree.h (splay_tree_compare_strings, [...]): Declare new utility functions. include: 2018-05-28 Bernd Edlinger * splay-tree.h (splay_tree_compare_strings, splay_tree_delete_pointers): Declare new utility functions. libiberty: 2018-05-28 Bernd Edlinger * splay-tree.c (splay_tree_compare_strings, splay_tree_delete_pointers): New utility functions. gcc: 2018-05-28 Bernd Edlinger * tree-dump.c (dump_node): Use splay_tree_delete_pointers. c-family: 2018-05-28 Bernd Edlinger * c-lex.c (get_fileinfo): Use splay_tree_compare_strings and splay_tree_delete_pointers. cp: 2018-05-28 Bernd Edlinger * decl2.c (start_static_storage_duration_function): Use splay_tree_delete_pointers. From-SVN: r260850 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 58ab2b4ed46..8791af2982e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2018-05-28 Bernd Edlinger + + * tree-dump.c (dump_node): Use splay_tree_delete_pointers. + 2018-05-28 Richard Biener PR tree-optimization/85933 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 4fc2f1bfad2..40565d68fdc 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2018-05-28 Bernd Edlinger + + * c-lex.c (get_fileinfo): Use splay_tree_compare_strings and + splay_tree_delete_pointers. + 2018-05-26 Jakub Jelinek PR bootstrap/85921 diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index a4ad0a30f38..3cd24ac40dc 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -103,11 +103,9 @@ get_fileinfo (const char *name) struct c_fileinfo *fi; if (!file_info_tree) - file_info_tree = splay_tree_new ((splay_tree_compare_fn) - (void (*) (void)) strcmp, + file_info_tree = splay_tree_new (splay_tree_compare_strings, 0, - (splay_tree_delete_value_fn) - (void (*) (void)) free); + splay_tree_delete_pointers); n = splay_tree_lookup (file_info_tree, (splay_tree_key) name); if (n) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 58fc696c571..a3a443a69b9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-05-28 Bernd Edlinger + + * decl2.c (start_static_storage_duration_function): Use + splay_tree_delete_pointers. + 2018-05-25 Jason Merrill PR c++/85815 - reference to member of enclosing template. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index e16e476c285..2cef9c750ed 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3595,8 +3595,7 @@ start_static_storage_duration_function (unsigned count) priority_info_map = splay_tree_new (splay_tree_compare_ints, /*delete_key_fn=*/0, /*delete_value_fn=*/ - (splay_tree_delete_value_fn) - (void (*) (void)) free); + splay_tree_delete_pointers); /* We always need to generate functions for the DEFAULT_INIT_PRIORITY so enter it now. That way when we walk diff --git a/gcc/tree-dump.c b/gcc/tree-dump.c index fe3cc12bf23..fd565d207a8 100644 --- a/gcc/tree-dump.c +++ b/gcc/tree-dump.c @@ -732,8 +732,7 @@ dump_node (const_tree t, dump_flags_t flags, FILE *stream) di.flags = flags; di.node = t; di.nodes = splay_tree_new (splay_tree_compare_pointers, 0, - (splay_tree_delete_value_fn) - (void (*) (void)) free); + splay_tree_delete_pointers); /* Queue up the first node. */ queue (&di, t, DUMP_NONE); diff --git a/include/ChangeLog b/include/ChangeLog index 854b58af083..7b4aaed39c1 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2018-05-28 Bernd Edlinger + + * splay-tree.h (splay_tree_compare_strings, + splay_tree_delete_pointers): Declare new utility functions. + 2018-05-24 Tom Rix * dwarf2.def (DW_FORM_strx*, DW_FORM_addrx*): New. diff --git a/include/splay-tree.h b/include/splay-tree.h index b63612cc0a4..fc94fb786fb 100644 --- a/include/splay-tree.h +++ b/include/splay-tree.h @@ -147,7 +147,9 @@ extern splay_tree_node splay_tree_max (splay_tree); extern splay_tree_node splay_tree_min (splay_tree); extern int splay_tree_foreach (splay_tree, splay_tree_foreach_fn, void*); extern int splay_tree_compare_ints (splay_tree_key, splay_tree_key); -extern int splay_tree_compare_pointers (splay_tree_key, splay_tree_key); +extern int splay_tree_compare_pointers (splay_tree_key, splay_tree_key); +extern int splay_tree_compare_strings (splay_tree_key, splay_tree_key); +extern void splay_tree_delete_pointers (splay_tree_value); #ifdef __cplusplus } diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index b249226155c..19c62699c07 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2018-05-28 Bernd Edlinger + + * splay-tree.c (splay_tree_compare_strings, + splay_tree_delete_pointers): New utility functions. + 2018-05-10 Martin Liska PR bootstrap/64914 diff --git a/libiberty/splay-tree.c b/libiberty/splay-tree.c index 23d22a89d8e..d3be4aa90b5 100644 --- a/libiberty/splay-tree.c +++ b/libiberty/splay-tree.c @@ -31,6 +31,9 @@ Boston, MA 02110-1301, USA. */ #ifdef HAVE_STDLIB_H #include #endif +#ifdef HAVE_STRING_H +#include +#endif #include @@ -590,3 +593,19 @@ splay_tree_compare_pointers (splay_tree_key k1, splay_tree_key k2) else return 0; } + +/* Splay-tree comparison function, treating the keys as strings. */ + +int +splay_tree_compare_strings (splay_tree_key k1, splay_tree_key k2) +{ + return strcmp ((char *) k1, (char *) k2); +} + +/* Splay-tree delete function, simply using free. */ + +void +splay_tree_delete_pointers (splay_tree_value value) +{ + free ((void *) value); +}