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

Re: New ARI regression Fri Oct 23 01:57:01 UTC 2009


Pedro Alves wrote:

These functions aren't always "network order" now, and are
hence misnamed.  Rename or eliminate them by inlining they
bodies at the call sites.  Alternatively, if you wanted to
keep using "netorder", you could just simply always
hardcode BFD_ENDIAN_BIG, or pull htonl from gnulib.


Yeah. Sorry for all the back-and-forth. I like the last idea. How's this patch?



2009-10-23  Michael Snyder  <msnyder@vmware.com>

	* record.c (top level): Don't include byteswap.h.
	(netorder64): Use store_unsigned_integer instead of bswap_64.
	(netorder32): Use store_unsigned_integer instead of bswap_32.
	(netorder16): Use store_unsigned_integer instead of bswap_16.

Index: record.c
===================================================================
RCS file: /cvs/src/src/gdb/record.c,v
retrieving revision 1.34
diff -u -p -r1.34 record.c
--- record.c	23 Oct 2009 17:12:25 -0000	1.34
+++ record.c	23 Oct 2009 22:33:56 -0000
@@ -31,7 +31,6 @@
 #include "elf-bfd.h"
 #include "gcore.h"
 
-#include <byteswap.h>
 #include <signal.h>
 
 /* This module implements "target record", also known as "process
@@ -1956,27 +1955,33 @@ bfdcore_read (bfd *obfd, asection *osec,
 }
 
 static inline uint64_t
-netorder64 (uint64_t fromfile)
+netorder64 (uint64_t input)
 {
-  return (BYTE_ORDER == BFD_ENDIAN_LITTLE) 
-    ? bswap_64 (fromfile) 
-    : fromfile;
+  uint64_t ret;
+
+  store_unsigned_integer ((gdb_byte *) &ret, sizeof (ret), 
+			  BFD_ENDIAN_BIG, input);
+  return ret;
 }
 
 static inline uint32_t
-netorder32 (uint32_t fromfile)
+netorder32 (uint32_t input)
 {
-  return (BYTE_ORDER == BFD_ENDIAN_LITTLE) 
-    ? bswap_32 (fromfile) 
-    : fromfile;
+  uint32_t ret;
+
+  store_unsigned_integer ((gdb_byte *) &ret, sizeof (ret), 
+			  BFD_ENDIAN_BIG, input);
+  return ret;
 }
 
 static inline uint16_t
-netorder16 (uint16_t fromfile)
+netorder16 (uint16_t input)
 {
-  return (BYTE_ORDER == BFD_ENDIAN_LITTLE) 
-    ? bswap_16 (fromfile) 
-    : fromfile;
+  uint16_t ret;
+
+  store_unsigned_integer ((gdb_byte *) &ret, sizeof (ret), 
+			  BFD_ENDIAN_BIG, input);
+  return ret;
 }
 
 /* Restore the execution log from a core_bfd file.  */

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