sim: callback: add missing cb_target_to_host_signal
authorMike Frysinger <vapier@gentoo.org>
Sun, 20 Jun 2021 16:53:38 +0000 (12:53 -0400)
committerMike Frysinger <vapier@gentoo.org>
Tue, 22 Jun 2021 23:38:48 +0000 (19:38 -0400)
There's been a prototype for this forever, but the implementation was
missing.  Probably because there weren't any callers, but we'll start
using it to implement the kill function.

sim/common/ChangeLog
sim/common/callback.c

index 5ce1a66dd0e0d3fc816797910965b5672f5519fd..fdfeca9b9a5621a87d969c6d282a8cd165b6195f 100644 (file)
@@ -1,3 +1,7 @@
+2021-06-22  Mike Frysinger  <vapier@gentoo.org>
+
+       * callback.c (cb_target_to_host_signal): New function.
+
 2021-06-22  Mike Frysinger  <vapier@gentoo.org>
 
        * callback.c: Include signal.h.
index aca0112853c46da3a9b8b88ea68b48256aa7c523..06d76b47724576bce9d6ad1daa6426771b520045 100644 (file)
@@ -927,6 +927,19 @@ cb_target_to_host_open (host_callback *cb, int target_val)
   return host_val;
 }
 
+/* Translate the target's version of a signal number to the host's.
+   This isn't actually the host's version, rather a canonical form.
+   ??? Perhaps this should be renamed to ..._canon_signal.  */
+
+int
+cb_target_to_host_signal (host_callback *cb, int target_val)
+{
+  const CB_TARGET_DEFS_MAP *m =
+    cb_target_map_entry (cb->signal_map, target_val);
+
+  return m ? m->host_val : -1;
+}
+
 /* Utility for e.g. cb_host_to_target_stat to store values in the target's
    stat struct.