This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Please use attached 0002*patch file, which added my missing email address in the signed-off line. Thanks. On Wed, Oct 21, 2015 at 3:50 PM, Chih-Hung Hsieh <chh@google.com> wrote: > * Nested functions in these two files are moved to file scope > to compile with clang. Extra parameters are added to pass > local variables. > > Signed-off-by: Chih-Hung Hsieh > --- > libdwfl/ChangeLog | 7 +++++++ > libdwfl/dwfl_module.c | 33 +++++++++++++++++---------------- > libdwfl/dwfl_module_getsrc_file.c | 31 ++++++++++++++++++------------- > 3 files changed, 42 insertions(+), 29 deletions(-) > > diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog > index 5cae434..0374e5a 100644 > --- a/libdwfl/ChangeLog > +++ b/libdwfl/ChangeLog > @@ -1,3 +1,10 @@ > +2015-10-21 Chih-Hung Hsieh <chh@google.com> > + > + * dwfl_module.c (dwfl_report_module): Move nested function 'use' > to file > + scope. > + * dwfl_module_getsrc_file.c (dwfl_module_getsrc_file): Move nested > functions > + 'dwarf_line_file', 'dwfl_line', and 'dwfl_line_file' to file scope. > + > 2015-10-09 Josh Stone <jistone@redhat.com> > > * core-file.c (elf_begin_rand): Replace loff_t with off_t. > diff --git a/libdwfl/dwfl_module.c b/libdwfl/dwfl_module.c > index 8efcfaa..76d45a8 100644 > --- a/libdwfl/dwfl_module.c > +++ b/libdwfl/dwfl_module.c > @@ -125,6 +125,21 @@ dwfl_report_begin (Dwfl *dwfl) > } > INTDEF (dwfl_report_begin) > > +static inline Dwfl_Module * > +use (Dwfl_Module *mod, Dwfl_Module **tailp, Dwfl *dwfl) > +{ > + mod->next = *tailp; > + *tailp = mod; > + > + if (unlikely (dwfl->lookup_module != NULL)) > + { > + free (dwfl->lookup_module); > + dwfl->lookup_module = NULL; > + } > + > + return mod; > +} > + > /* Report that a module called NAME spans addresses [START, END). > Returns the module handle, either existing or newly allocated, > or returns a null pointer for an allocation error. */ > @@ -134,20 +149,6 @@ dwfl_report_module (Dwfl *dwfl, const char *name, > { > Dwfl_Module **tailp = &dwfl->modulelist, **prevp = tailp; > > - inline Dwfl_Module *use (Dwfl_Module *mod) > - { > - mod->next = *tailp; > - *tailp = mod; > - > - if (unlikely (dwfl->lookup_module != NULL)) > - { > - free (dwfl->lookup_module); > - dwfl->lookup_module = NULL; > - } > - > - return mod; > - } > - > for (Dwfl_Module *m = *prevp; m != NULL; m = *(prevp = &m->next)) > { > if (m->low_addr == start && m->high_addr == end > @@ -157,7 +158,7 @@ dwfl_report_module (Dwfl *dwfl, const char *name, > after the last module already reported. */ > *prevp = m->next; > m->gc = false; > - return use (m); > + return use (m, tailp, dwfl); > } > > if (! m->gc) > @@ -181,7 +182,7 @@ dwfl_report_module (Dwfl *dwfl, const char *name, > mod->high_addr = end; > mod->dwfl = dwfl; > > - return use (mod); > + return use (mod, tailp, dwfl); > } > INTDEF (dwfl_report_module) > > diff --git a/libdwfl/dwfl_module_getsrc_file.c > b/libdwfl/dwfl_module_getsrc_file.c > index 20aa8a5..75ba68e 100644 > --- a/libdwfl/dwfl_module_getsrc_file.c > +++ b/libdwfl/dwfl_module_getsrc_file.c > @@ -30,6 +30,24 @@ > #include "../libdw/libdwP.h" > > > +static inline const char * > +INTUSE(dwarf_line_file) (const Dwarf_Line *line) > +{ > + return line->files->info[line->file].name; > +} > + > +static inline Dwarf_Line * > +dwfl_line (const Dwfl_Line *line) > +{ > + return &dwfl_linecu (line)->die.cu->lines->info[line->idx]; > +} > + > +static inline const char * > +dwfl_line_file (const Dwfl_Line *line) > +{ > + return INTUSE(dwarf_line_file) (dwfl_line (line)); > +} > + > int > dwfl_module_getsrc_file (Dwfl_Module *mod, > const char *fname, int lineno, int column, > @@ -58,19 +76,6 @@ dwfl_module_getsrc_file (Dwfl_Module *mod, > && cu != NULL > && (error = __libdwfl_cu_getsrclines (cu)) == DWFL_E_NOERROR) > { > - inline const char *INTUSE(dwarf_line_file) (const Dwarf_Line *line) > - { > - return line->files->info[line->file].name; > - } > - inline Dwarf_Line *dwfl_line (const Dwfl_Line *line) > - { > - return &dwfl_linecu (line)->die.cu->lines->info[line->idx]; > - } > - inline const char *dwfl_line_file (const Dwfl_Line *line) > - { > - return INTUSE(dwarf_line_file) (dwfl_line (line)); > - } > - > /* Search through all the line number records for a matching > file and line/column number. If any of the numbers is zero, > no match is performed. */ > -- > 2.6.0.rc2.230.g3dd15c0 > >
* Nested functions in these two files are moved to file scope
 to compile with clang. Extra parameters are added to pass
 local variables.
Signed-off-by: Chih-Hung Hsieh
---
 libdwfl/ChangeLog         | 7 +++++++
 libdwfl/dwfl_module.c       | 33 +++++++++++++++++----------------
 libdwfl/dwfl_module_getsrc_file.c | 31 ++++++++++++++++++-------------
 3 files changed, 42 insertions(+), 29 deletions(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 5cae434..0374e5a 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,10 @@
+2015-10-21Â Chih-Hung Hsieh <chh@google.com>
+
+Â Â Â Â * dwfl_module.c (dwfl_report_module): Move nested function 'use' to file
+Â Â Â Â scope.
+Â Â Â Â * dwfl_module_getsrc_file.c (dwfl_module_getsrc_file): Move nested functions
+Â Â Â Â 'dwarf_line_file', 'dwfl_line', and 'dwfl_line_file' to file scope.
+
 2015-10-09 Josh Stone <jistone@redhat.com>
    * core-file.c (elf_begin_rand): Replace loff_t with off_t.
diff --git a/libdwfl/dwfl_module.c b/libdwfl/dwfl_module.c
index 8efcfaa..76d45a8 100644
--- a/libdwfl/dwfl_module.c
+++ b/libdwfl/dwfl_module.c
@@ -125,6 +125,21 @@ dwfl_report_begin (Dwfl *dwfl)
 }
 INTDEF (dwfl_report_begin)
+static inline Dwfl_Module *
+use (Dwfl_Module *mod, Dwfl_Module **tailp, Dwfl *dwfl)
+{
+Â mod->next = *tailp;
+Â *tailp = mod;
+
+Â if (unlikely (dwfl->lookup_module != NULL))
+Â Â {
+Â Â Â free (dwfl->lookup_module);
+Â Â Â dwfl->lookup_module = NULL;
+Â Â }
+
+Â return mod;
+}
+
 /* Report that a module called NAME spans addresses [START, END).
  Returns the module handle, either existing or newly allocated,
  or returns a null pointer for an allocation error. */
@@ -134,20 +149,6 @@ dwfl_report_module (Dwfl *dwfl, const char *name,
 {
  Dwfl_Module **tailp = &dwfl->modulelist, **prevp = tailp;
-Â inline Dwfl_Module *use (Dwfl_Module *mod)
-Â {
-Â Â mod->next = *tailp;
-Â Â *tailp = mod;
-
-Â Â if (unlikely (dwfl->lookup_module != NULL))
-Â Â Â {
-Â Â Â Â free (dwfl->lookup_module);
-Â Â Â Â dwfl->lookup_module = NULL;
-Â Â Â }
-
-Â Â return mod;
-Â }
-
  for (Dwfl_Module *m = *prevp; m != NULL; m = *(prevp = &m->next))
   {
    if (m->low_addr == start && m->high_addr == end
@@ -157,7 +158,7 @@ dwfl_report_module (Dwfl *dwfl, const char *name,
       after the last module already reported. */
     *prevp = m->next;
     m->gc = false;
-Â Â Â Â Â return use (m);
+Â Â Â Â Â return use (m, tailp, dwfl);
    }
    if (! m->gc)
@@ -181,7 +182,7 @@ dwfl_report_module (Dwfl *dwfl, const char *name,
  mod->high_addr = end;
  mod->dwfl = dwfl;
-Â return use (mod);
+Â return use (mod, tailp, dwfl);
 }
 INTDEF (dwfl_report_module)
diff --git a/libdwfl/dwfl_module_getsrc_file.c b/libdwfl/dwfl_module_getsrc_file.c
index 20aa8a5..75ba68e 100644
--- a/libdwfl/dwfl_module_getsrc_file.c
+++ b/libdwfl/dwfl_module_getsrc_file.c
@@ -30,6 +30,24 @@
 #include "../libdw/libdwP.h"
+static inline const char *
+INTUSE(dwarf_line_file) (const Dwarf_Line *line)
+{
+Â return line->files->info[line->file].name;
+}
+
+static inline Dwarf_Line *
+dwfl_line (const Dwfl_Line *line)
+{
+Â return &dwfl_linecu (line)->die.cu->lines->info[line->idx];
+}
+
+static inline const char *
+dwfl_line_file (const Dwfl_Line *line)
+{
+Â return INTUSE(dwarf_line_file) (dwfl_line (line));
+}
+
 int
 dwfl_module_getsrc_file (Dwfl_Module *mod,
             const char *fname, int lineno, int column,
@@ -58,19 +76,6 @@ dwfl_module_getsrc_file (Dwfl_Module *mod,
     && cu != NULL
     && (error = __libdwfl_cu_getsrclines (cu)) == DWFL_E_NOERROR)
   {
-Â Â Â inline const char *INTUSE(dwarf_line_file) (const Dwarf_Line *line)
-Â Â Â Â {
-Â Â Â Â Â return line->files->info[line->file].name;
-Â Â Â Â }
-Â Â Â inline Dwarf_Line *dwfl_line (const Dwfl_Line *line)
-Â Â Â Â {
-Â Â Â Â Â return &dwfl_linecu (line)->die.cu->lines->info[line->idx];
-Â Â Â Â }
-Â Â Â inline const char *dwfl_line_file (const Dwfl_Line *line)
-Â Â Â Â {
-Â Â Â Â Â return INTUSE(dwarf_line_file) (dwfl_line (line));
-Â Â Â Â }
-
    /* Search through all the line number records for a matching
     file and line/column number. If any of the numbers is zero,
     no match is performed. */
--
2.6.0.rc2.230.g3dd15c0
Attachment:
0002-Move-nested-functions-in-dwfl_module.c-and-dwfl_modu.patch
Description: Binary data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |