This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils 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]

[binutils-gdb] Don't include libbfd.h outside of bfd, part 4


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4212b42d795628dcc36bcffc7cf16175f7698305

commit 4212b42d795628dcc36bcffc7cf16175f7698305
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Jul 16 13:29:35 2016 +0930

    Don't include libbfd.h outside of bfd, part 4
    
    Not much to see here, just renaming a function.
    
    bfd/
    	* targets.c (bfd_seach_for_target): Rename to..
    	(bfd_iterate_over_targets): ..this.  Rewrite doc.
    	* bfd-in2.h: Regenerate.
    ld/
    	* ldlang.c (open_output): Replace bfd_search_for_target with
    	bfd_iterate_over_targets.  Localize vars.

Diff:
---
 bfd/ChangeLog |  6 ++++++
 bfd/bfd-in2.h |  6 +++---
 bfd/targets.c | 27 +++++++++++++--------------
 ld/ChangeLog  |  5 +++++
 ld/ldlang.c   | 12 ++++++------
 5 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ba678b6..bf79618 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
 2016-07-16  Alan Modra  <amodra@gmail.com>
 
+	* targets.c (bfd_seach_for_target): Rename to..
+	(bfd_iterate_over_targets): ..this.  Rewrite doc.
+	* bfd-in2.h: Regenerate.
+
+2016-07-16  Alan Modra  <amodra@gmail.com>
+
 	* archures.c (bfd_default_set_arch_mach): Make available in bfd.h.
 	* libbfd.h: Regenerate.
 	* bfd-in2.h: Regenerate.
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 8b12547..f9f0e26 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7555,9 +7555,9 @@ const bfd_target *bfd_get_target_info (const char *target_name,
     const char **def_target_arch);
 const char ** bfd_target_list (void);
 
-const bfd_target *bfd_search_for_target
-   (int (*search_func) (const bfd_target *, void *),
-    void *);
+const bfd_target *bfd_iterate_over_targets
+   (int (*func) (const bfd_target *, void *),
+    void *data);
 
 const char *bfd_flavour_name (enum bfd_flavour flavour);
 
diff --git a/bfd/targets.c b/bfd/targets.c
index a9edd4c..19d442a 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -1815,29 +1815,28 @@ bfd_target_list (void)
 
 /*
 FUNCTION
-	bfd_seach_for_target
+	bfd_iterate_over_targets
 
 SYNOPSIS
-	const bfd_target *bfd_search_for_target
-	  (int (*search_func) (const bfd_target *, void *),
-	   void *);
+	const bfd_target *bfd_iterate_over_targets
+	  (int (*func) (const bfd_target *, void *),
+	   void *data);
 
 DESCRIPTION
-	Return a pointer to the first transfer vector in the list of
-	transfer vectors maintained by BFD that produces a non-zero
-	result when passed to the function @var{search_func}.  The
-	parameter @var{data} is passed, unexamined, to the search
-	function.
+	Call @var{func} for each target in the list of BFD target
+	vectors, passing @var{data} to @var{func}.  Stop iterating if
+	@var{func} returns a non-zero result, and return that target
+	vector.  Return NULL if @var{func} always returns zero.
 */
 
 const bfd_target *
-bfd_search_for_target (int (*search_func) (const bfd_target *, void *),
-		       void *data)
+bfd_iterate_over_targets (int (*func) (const bfd_target *, void *),
+			  void *data)
 {
-  const bfd_target * const *target;
+  const bfd_target *const *target;
 
-  for (target = bfd_target_vector; *target != NULL; target ++)
-    if (search_func (*target, data))
+  for (target = bfd_target_vector; *target != NULL; ++target)
+    if (func (*target, data))
       return *target;
 
   return NULL;
diff --git a/ld/ChangeLog b/ld/ChangeLog
index b7be656..e4026ec 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,10 @@
 2016-07-16  Alan Modra  <amodra@gmail.com>
 
+	* ldlang.c (open_output): Replace bfd_search_for_target with
+	bfd_iterate_over_targets.  Localize vars.
+
+2016-07-16  Alan Modra  <amodra@gmail.com>
+
 	* ldlang.c: Don't include libbfd.h.
 	* emultempl/nds32elf.em: Likewise.
 	* emultempl/ppc64elf.em: Likewise.
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 82d5582..aee8720 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -3113,15 +3113,15 @@ open_output (const char *name)
      line?  */
   if (command_line.endian != ENDIAN_UNSET)
     {
-      const bfd_target *target;
-      enum bfd_endian desired_endian;
-
       /* Get the chosen target.  */
-      target = bfd_search_for_target (get_target, (void *) output_target);
+      const bfd_target *target
+	= bfd_iterate_over_targets (get_target, (void *) output_target);
 
       /* If the target is not supported, we cannot do anything.  */
       if (target != NULL)
 	{
+	  enum bfd_endian desired_endian;
+
 	  if (command_line.endian == ENDIAN_BIG)
 	    desired_endian = BFD_ENDIAN_BIG;
 	  else
@@ -3143,8 +3143,8 @@ open_output (const char *name)
 		  /* Try to find a target as similar as possible to
 		     the default target, but which has the desired
 		     endian characteristic.  */
-		  bfd_search_for_target (closest_target_match,
-					 (void *) target);
+		  bfd_iterate_over_targets (closest_target_match,
+					    (void *) target);
 
 		  /* Oh dear - we could not find any targets that
 		     satisfy our requirements.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]