22 #include "splay-tree.h"
23 #include "filenames.h"
89 return obstack_alloc (t->
obstack, size);
121 memcpy (copy, addr, len);
252 while (depth1 > depth2)
259 while (depth2 > depth1)
269 while (file1 != file2)
306 return line1 - line2;
323 int names = strcmp (key->
name, name);
337 splay_tree_key untyped_key2)
357 memset (k, 0,
sizeof (*k));
390 memset (f, 0,
sizeof (*f));
406 for (child = src->
includes; child; child = next_child)
451 const char *included)
468 char *link_fullname, *source_fullname;
481 _(
"both `%s' and `%s' allegedly #included at %s:%d"),
482 included, link_fullname, source_fullname, line);
483 xfree (source_fullname);
484 xfree (link_fullname);
513 if (filename_cmp (name, source->
filename) == 0)
531 if (! best || result_depth < best_depth)
534 best_depth = result_depth;
558 memset (d, 0,
sizeof (*d));
567 const char **cached_argv;
568 int cached_argv_size = argc *
sizeof (*cached_argv);
571 cached_argv = alloca (cached_argv_size);
572 for (i = 0; i <
argc; i++)
611 for (i = 0; i < d->
argc; i++)
623 static splay_tree_node
639 n = splay_tree_lookup (t->
definitions, (splay_tree_key) &query);
648 splay_tree_node pred = splay_tree_predecessor (t->
definitions,
649 (splay_tree_key) &query);
657 if (strcmp (found->
name, name) == 0)
687 int argc,
const char **argv,
688 const char *replacement)
706 if (kind != found_def->kind)
708 else if (strcmp (replacement, found_def->replacement))
712 if (argc != found_def->argc)
718 for (i = 0; i < argc; i++)
719 if (strcmp (argv[i], found_def->argv[i]))
726 char *source_fullname, *found_key_fullname;
731 _(
"macro `%s' redefined at %s:%d; "
732 "original definition at %s:%d"),
733 name, source_fullname, line, found_key_fullname,
735 xfree (found_key_fullname);
736 xfree (source_fullname);
749 const char *
name,
const char *replacement,
777 splay_tree_insert (t->
definitions, (splay_tree_key) k, (splay_tree_value) d);
823 splay_tree_insert (t->
definitions, (splay_tree_key) k, (splay_tree_value) d);
855 char *source_fullname, *key_fullname;
860 _(
"macro '%s' is #undefined twice,"
861 " at %s:%d and %s:%d"),
862 name, source_fullname, line, key_fullname,
864 xfree (key_fullname);
865 xfree (source_fullname);
881 _(
"no definition for macro `%s' in scope to #undef at %s:%d"),
893 static char *saved_expansion;
897 xfree (saved_expansion);
898 saved_expansion = NULL;
927 char *source_fullname;
932 xfree (source_fullname);
944 int *definition_line)
983 xfree (key_fullname);
1010 char *datum_fullname;
1015 xfree (datum_fullname);
1057 t = obstack_alloc (obstack,
sizeof (*t));
1061 memset (t, 0,
sizeof (*t));
1094 const char *comp_dir = NULL;
1099 if (comp_dir == NULL || IS_ABSOLUTE_PATH (file->
filename))
void macro_define_function(struct macro_source_file *source, int line, const char *name, int argc, const char **argv, const char *replacement)
struct macro_source_file * next_included
void(* macro_callback_fn)(const char *name, const struct macro_definition *definition, struct macro_source_file *source, int line, void *user_data)
static void macro_define_object_internal(struct macro_source_file *source, int line, const char *name, const char *replacement, enum macro_special_kind kind)
static struct macro_key * check_for_redefinition(struct macro_source_file *source, int line, const char *name, enum macro_kind kind, int argc, const char **argv, const char *replacement)
const void * bcache(const void *addr, int length, struct bcache *cache)
struct macro_table * table
__extension__ enum macro_kind kind
struct macro_table * table
struct macro_table * table
struct macro_source_file * includes
struct macro_source_file * included_by
struct compunit_symtab * compunit_symtab
struct macro_source_file * macro_lookup_inclusion(struct macro_source_file *source, const char *name)
static int macro_tree_compare(splay_tree_key untyped_key1, splay_tree_key untyped_key2)
static const char * macro_bcache_str(struct macro_table *t, const char *s)
void macro_for_each_in_scope(struct macro_source_file *file, int line, macro_callback_fn fn, void *user_data)
static const void * macro_bcache(struct macro_table *t, const void *addr, int len)
static int inclusion_depth(struct macro_source_file *file)
#define COMPUNIT_DIRNAME(cust)
void macro_define_object(struct macro_source_file *source, int line, const char *name, const char *replacement)
static void * macro_alloc(int size, struct macro_table *t)
static struct macro_definition * fixup_definition(const char *filename, int line, struct macro_definition *def)
struct macro_source_file * file
static int compare_locations(struct macro_source_file *file1, int line1, struct macro_source_file *file2, int line2)
struct macro_definition * macro_lookup_definition(struct macro_source_file *source, int line, const char *name)
static void macro_tree_delete_key(void *untyped_key)
void complaint(struct complaints **complaints, const char *fmt,...)
static int foreach_macro(splay_tree_node node, void *arg)
struct macro_source_file * macro_include(struct macro_source_file *source, int line, const char *included)
void macro_define_special(struct macro_table *table)
char * xstrprintf(const char *format,...)
static struct macro_source_file * new_source_file(struct macro_table *t, const char *filename)
char * macro_source_fullname(struct macro_source_file *file)
char * macro_stringify(const char *str)
struct macro_source_file * macro_definition_location(struct macro_source_file *source, int line, const char *name, int *definition_line)
void macro_for_each(struct macro_table *table, macro_callback_fn fn, void *user_data)
static struct macro_definition * new_macro_definition(struct macro_table *t, enum macro_kind kind, int argc, const char **argv, const char *replacement)
static struct macro_key * new_macro_key(struct macro_table *t, const char *name, struct macro_source_file *file, int line)
static splay_tree_node find_definition(const char *name, struct macro_source_file *file, int line)
static int key_compare(struct macro_key *key, const char *name, struct macro_source_file *file, int line)
struct macro_source_file * end_file
struct complaints * symfile_complaints
struct macro_source_file * main_source
static void macro_tree_delete_value(void *untyped_definition)
void free_macro_table(struct macro_table *table)
static void free_macro_source_file(struct macro_source_file *src)
struct macro_source_file * start_file
static void macro_free(void *object, struct macro_table *t)
struct macro_source_file * macro_set_main(struct macro_table *t, const char *filename)
void macro_allow_redefinitions(struct macro_table *t)
struct macro_source_file * macro_main(struct macro_table *t)
static void macro_bcache_free(struct macro_table *t, void *obj)
static int foreach_macro_in_scope(splay_tree_node node, void *info)
void macro_undef(struct macro_source_file *source, int line, const char *name)
struct macro_table * new_macro_table(struct obstack *obstack, struct bcache *b, struct compunit_symtab *cust)
const ULONGEST const LONGEST len