Add GPL copyright notices to uncopyrighted files.
[deliverable/binutils-gdb.git] / gdb / utils.c
index f5088aff82d51b90564e832b0254083afde8f5d3..a1214daef06a7d10e6a90db61c1cf9dcd9a6b479 100644 (file)
@@ -50,6 +50,8 @@
 #include "language.h"
 #include "annotate.h"
 
+#include "inferior.h" /* for signed_pointer_to_address */
+
 #include <readline/readline.h>
 
 #undef XMALLOC
@@ -1490,7 +1492,7 @@ fputstrn_unfiltered (str, n, quoter, stream)
 
 /* Number of lines per page or UINT_MAX if paging is disabled.  */
 static unsigned int lines_per_page;
-/* Number of chars per line or UNIT_MAX if line folding is disabled.  */
+/* Number of chars per line or UINT_MAX if line folding is disabled.  */
 static unsigned int chars_per_line;
 /* Current count of lines printed on this page, chars on this line.  */
 static unsigned int lines_printed, chars_printed;
@@ -2962,3 +2964,24 @@ phex_nz (ULONGEST l, int sizeof_l)
     }
   return str;
 }
+
+
+/* Convert to / from the hosts pointer to GDB's internal CORE_ADDR
+   using the target's conversion routines. */
+CORE_ADDR
+host_pointer_to_address (void *ptr)
+{
+  if (sizeof (ptr) != TYPE_LENGTH (builtin_type_ptr))
+    internal_error ("core_addr_to_void_ptr: bad cast");
+  return POINTER_TO_ADDRESS (builtin_type_ptr, &ptr);
+}
+
+void *
+address_to_host_pointer (CORE_ADDR addr)
+{
+  void *ptr;
+  if (sizeof (ptr) != TYPE_LENGTH (builtin_type_ptr))
+    internal_error ("core_addr_to_void_ptr: bad cast");
+  ADDRESS_TO_POINTER (builtin_type_ptr, &ptr, addr);
+  return ptr;
+}
This page took 0.024671 seconds and 4 git commands to generate.