This is the mail archive of the gdb-patches@sources.redhat.com 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]

[patch/remote-array.c] Eliminate HOST_BYTE_ORDER


Hello,

The attached path eliminates references to HOST_BYTE_ORDER from the file 
remote-array.c.  It uses more generic host/target conversion functions 
instead.

	Andrew
2001-06-28  Andrew Cagney  <ac131313@redhat.com>

	* remote-array.c (SWAP_TARGET_AND_HOST): Delete macro.
	(get_hex_word): Don't use HOST_BYTE_ORDER.
	(array_fetch_registers): Add variable ``reg''.  Use
	store_unsigned_integer to byte-swap the register.  Delete unused
	local ``regs''.

Index: remote-array.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-array.c,v
retrieving revision 1.14
diff -p -r1.14 remote-array.c
*** remote-array.c	2001/05/04 04:15:26	1.14
--- remote-array.c	2001/06/29 04:32:28
*************** extern int baud_rate;
*** 44,67 ****
  
  #define ARRAY_PROMPT ">> "
  
- #define SWAP_TARGET_AND_HOST(buffer,len) 				\
-   do									\
-     {									\
-       if (TARGET_BYTE_ORDER != HOST_BYTE_ORDER)				\
- 	{								\
- 	  char tmp;							\
- 	  char *p = (char *)(buffer);					\
- 	  char *q = ((char *)(buffer)) + len - 1;		   	\
- 	  for (; p < q; p++, q--)				 	\
- 	    {								\
- 	      tmp = *q;							\
- 	      *q = *p;							\
- 	      *p = tmp;							\
- 	    }								\
- 	}								\
-     }									\
-   while (0)
- 
  static void debuglogs (int, char *, ...);
  static void array_open ();
  static void array_close ();
--- 44,49 ----
*************** get_hex_word (void)
*** 508,529 ****
  
    val = 0;
  
! #if 0
!   if (HOST_BYTE_ORDER == BIG_ENDIAN)
!     {
! #endif
!       for (i = 0; i < 8; i++)
! 	val = (val << 4) + get_hex_digit (i == 0);
! #if 0
!     }
!   else
!     {
!       for (i = 7; i >= 0; i--)
! 	val = (val << 4) + get_hex_digit (i == 0);
!     }
! #endif
  
!   debuglogs (4, "get_hex_word() got a 0x%x for a %s host.", val, (HOST_BYTE_ORDER == BIG_ENDIAN) ? "big endian" : "little endian");
  
    return val;
  }
--- 490,499 ----
  
    val = 0;
  
!   for (i = 0; i < 8; i++)
!     val = (val << 4) + get_hex_digit (i == 0);
  
!   debuglogs (4, "get_hex_word() got a 0x%x.", val);
  
    return val;
  }
*************** array_wait (ptid_t ptid, struct target_w
*** 795,810 ****
  static void
  array_fetch_registers (int ignored)
  {
!   int regno, i;
    char *p;
!   unsigned char packet[PBUFSIZ];
!   char regs[REGISTER_BYTES];
  
    debuglogs (1, "array_fetch_registers (ignored=%d)\n", ignored);
  
    memset (packet, 0, PBUFSIZ);
-   /* Unimplemented registers read as all bits zero.  */
-   memset (regs, 0, REGISTER_BYTES);
    make_gdb_packet (packet, "g");
    if (array_send_packet (packet) == 0)
      error ("Couldn't transmit packet\n");
--- 765,778 ----
  static void
  array_fetch_registers (int ignored)
  {
!   char *reg = alloca (MAX_REGISTER_RAW_SIZE);
!   int regno;
    char *p;
!   char *packet = alloca (PBUFSIZ);
  
    debuglogs (1, "array_fetch_registers (ignored=%d)\n", ignored);
  
    memset (packet, 0, PBUFSIZ);
    make_gdb_packet (packet, "g");
    if (array_send_packet (packet) == 0)
      error ("Couldn't transmit packet\n");
*************** array_fetch_registers (int ignored)
*** 816,825 ****
      {
        /* supply register stores in target byte order, so swap here */
        /* FIXME: convert from ASCII hex to raw bytes */
!       i = ascii2hexword (packet + (regno * 8));
        debuglogs (5, "Adding register %d = %x\n", regno, i);
!       SWAP_TARGET_AND_HOST (&i, 4);
!       supply_register (regno, (char *) &i);
      }
  }
  
--- 784,793 ----
      {
        /* supply register stores in target byte order, so swap here */
        /* FIXME: convert from ASCII hex to raw bytes */
!       LONGEST i = ascii2hexword (packet + (regno * 8));
        debuglogs (5, "Adding register %d = %x\n", regno, i);
!       store_unsigned_integer (&reg, REGISTER_RAW_SIZE (regno), i);
!       supply_register (regno, (char *) &reg);
      }
  }
  

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