Mark guile_{extension_,}script_ops as static

Message ID 20191007223851.101950-1-cbiesinger@google.com
State New, archived
Headers

Commit Message

Terekhov, Mikhail via Gdb-patches Oct. 7, 2019, 10:38 p.m. UTC
  This makes it clearer that the structs are only used in this file. It
required moving the definition of extension_language_guile further
down in the file, because static structs can't be forward-declared.

gdb/ChangeLog:

2019-10-07  Christian Biesinger  <cbiesinger@google.com>

	* guile/guile.c (guile_extension_script_ops): Remove forward
	declaration and mark as static.
	(guile_script_ops): Likewise.
	(extension_language_guile): Move further down in the file so
	it can reference the definitions for guile_{extension_,}script_ops.
---
 gdb/guile/guile.c | 55 ++++++++++++++++++++++-------------------------
 1 file changed, 26 insertions(+), 29 deletions(-)
  

Comments

Tom Tromey Oct. 9, 2019, 5:48 p.m. UTC | #1
>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:

Christian> This makes it clearer that the structs are only used in this file. It
Christian> required moving the definition of extension_language_guile further
Christian> down in the file, because static structs can't be forward-declared.

Christian> gdb/ChangeLog:

Christian> 2019-10-07  Christian Biesinger  <cbiesinger@google.com>

Christian> 	* guile/guile.c (guile_extension_script_ops): Remove forward
Christian> 	declaration and mark as static.
Christian> 	(guile_script_ops): Likewise.
Christian> 	(extension_language_guile): Move further down in the file so
Christian> 	it can reference the definitions for guile_{extension_,}script_ops.

This is ok, thanks.

Tom
  
Terekhov, Mikhail via Gdb-patches Oct. 9, 2019, 6:19 p.m. UTC | #2
On Wed, Oct 9, 2019 at 12:48 PM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
>
> Christian> This makes it clearer that the structs are only used in this file. It
> Christian> required moving the definition of extension_language_guile further
> Christian> down in the file, because static structs can't be forward-declared.
>
> Christian> gdb/ChangeLog:
>
> Christian> 2019-10-07  Christian Biesinger  <cbiesinger@google.com>
>
> Christian>      * guile/guile.c (guile_extension_script_ops): Remove forward
> Christian>      declaration and mark as static.
> Christian>      (guile_script_ops): Likewise.
> Christian>      (extension_language_guile): Move further down in the file so
> Christian>      it can reference the definitions for guile_{extension_,}script_ops.
>
> This is ok, thanks.

Thanks, pushed:
To ssh://sourceware.org/git/binutils-gdb.git
   1d3787499d6..6a25e8a290e  HEAD -> master
Christian
  

Patch

diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c
index defe554f76..55929f4455 100644
--- a/gdb/guile/guile.c
+++ b/gdb/guile/guile.c
@@ -71,33 +71,6 @@  static const char *const guile_print_excp_enums[] =
    the default.  */
 const char *gdbscm_print_excp = gdbscm_print_excp_message;
 
-#ifdef HAVE_GUILE
-/* Forward decls, these are defined later.  */
-extern const struct extension_language_script_ops guile_extension_script_ops;
-extern const struct extension_language_ops guile_extension_ops;
-#endif
-
-/* The main struct describing GDB's interface to the Guile
-   extension language.  */
-extern const struct extension_language_defn extension_language_guile =
-{
-  EXT_LANG_GUILE,
-  "guile",
-  "Guile",
-
-  ".scm",
-  "-gdb.scm",
-
-  guile_control,
-
-#ifdef HAVE_GUILE
-  &guile_extension_script_ops,
-  &guile_extension_ops
-#else
-  NULL,
-  NULL
-#endif
-};
 
 #ifdef HAVE_GUILE
 
@@ -126,7 +99,7 @@  static const char boot_scm_filename[] = "boot.scm";
 
 /* The interface between gdb proper and loading of python scripts.  */
 
-const struct extension_language_script_ops guile_extension_script_ops =
+static const struct extension_language_script_ops guile_extension_script_ops =
 {
   gdbscm_source_script,
   gdbscm_source_objfile_script,
@@ -136,7 +109,7 @@  const struct extension_language_script_ops guile_extension_script_ops =
 
 /* The interface between gdb proper and guile scripting.  */
 
-const struct extension_language_ops guile_extension_ops =
+static const struct extension_language_ops guile_extension_ops =
 {
   gdbscm_finish_initialization,
   gdbscm_initialized,
@@ -159,7 +132,31 @@  const struct extension_language_ops guile_extension_ops =
   NULL, /* gdbscm_check_quit_flag, */
   NULL, /* gdbscm_set_quit_flag, */
 };
+#endif
+
+/* The main struct describing GDB's interface to the Guile
+   extension language.  */
+extern const struct extension_language_defn extension_language_guile =
+{
+  EXT_LANG_GUILE,
+  "guile",
+  "Guile",
+
+  ".scm",
+  "-gdb.scm",
 
+  guile_control,
+
+#ifdef HAVE_GUILE
+  &guile_extension_script_ops,
+  &guile_extension_ops
+#else
+  NULL,
+  NULL
+#endif
+};
+
+#ifdef HAVE_GUILE
 /* Implementation of the gdb "guile-repl" command.  */
 
 static void