]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Convert nto-tdep.c to type-safe registry API
authorTom Tromey <tom@tromey.com>
Wed, 1 May 2019 21:21:36 +0000 (15:21 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 8 May 2019 22:01:53 +0000 (16:01 -0600)
This changes nto-tdep.c to use the type-safe registry API.

gdb/ChangeLog
2019-05-08  Tom Tromey  <tom@tromey.com>

* nto-tdep.c (nto_inferior_data_reg): Change type.
(nto_inferior_data): Update.
(nto_inferior_data_cleanup, nto_new_inferior_data)
(_initialize_nto_tdep): Remove.
* nto-tdep.h (struct nto_inferior_data): Add initializers.

gdb/ChangeLog
gdb/nto-tdep.c
gdb/nto-tdep.h

index 4e6762afbcfda55016c85643ef48bae1f2640098..a8d727b87b1d4207b880cbf1aaacdbc203b9e098 100644 (file)
@@ -1,3 +1,11 @@
+2019-05-08  Tom Tromey  <tom@tromey.com>
+
+       * nto-tdep.c (nto_inferior_data_reg): Change type.
+       (nto_inferior_data): Update.
+       (nto_inferior_data_cleanup, nto_new_inferior_data)
+       (_initialize_nto_tdep): Remove.
+       * nto-tdep.h (struct nto_inferior_data): Add initializers.
+
 2019-05-08  Tom Tromey  <tom@tromey.com>
 
        * ada-lang.c (struct ada_inferior_data): Add initializers.
index 0caa55c2493ab4d18262527431431a5748961370..48e731acd05267d058bf455c27f98c0975fef70e 100644 (file)
@@ -51,7 +51,8 @@ static char default_nto_target[] = "";
 
 struct nto_target_ops current_nto_target;
 
-static const struct inferior_data *nto_inferior_data_reg;
+static const struct inferior_key<struct nto_inferior_data>
+  nto_inferior_data_reg;
 
 static char *
 nto_target (void)
@@ -498,25 +499,6 @@ nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack, gdb_byte *readbuf,
   return len_read;
 }
 
-/* Allocate new nto_inferior_data object.  */
-
-static struct nto_inferior_data *
-nto_new_inferior_data (void)
-{
-  struct nto_inferior_data *const inf_data
-    = XCNEW (struct nto_inferior_data);
-
-  return inf_data;
-}
-
-/* Free inferior data.  */
-
-static void
-nto_inferior_data_cleanup (struct inferior *const inf, void *const dat)
-{
-  xfree (dat);
-}
-
 /* Return nto_inferior_data for the given INFERIOR.  If not yet created,
    construct it.  */
 
@@ -528,20 +510,9 @@ nto_inferior_data (struct inferior *const inferior)
 
   gdb_assert (inf != NULL);
 
-  inf_data
-    = (struct nto_inferior_data *) inferior_data (inf, nto_inferior_data_reg);
+  inf_data = nto_inferior_data_reg.get (inf);
   if (inf_data == NULL)
-    {
-      set_inferior_data (inf, nto_inferior_data_reg,
-                        (inf_data = nto_new_inferior_data ()));
-    }
+    inf_data = nto_inferior_data_reg.emplace (inf);
 
   return inf_data;
 }
-
-void
-_initialize_nto_tdep (void)
-{
-  nto_inferior_data_reg
-    = register_inferior_data_with_cleanup (NULL, nto_inferior_data_cleanup);
-}
index 5127ab3f9ed64bc219da4f2fc71d5d567c0f1a72..2410a03a4a689a96c066cf53d8cd29edb77840e2 100644 (file)
@@ -152,10 +152,10 @@ get_nto_thread_info (thread_info *thread)
 struct nto_inferior_data
 {
   /* Last stopped flags result from wait function */
-  unsigned int stopped_flags;
+  unsigned int stopped_flags = 0;
 
   /* Last known stopped PC */
-  CORE_ADDR stopped_pc;
+  CORE_ADDR stopped_pc = 0;
 };
 
 /* Generic functions in nto-tdep.c.  */