aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2005-01-28 03:28:40 +0000
committerHans-Peter Nilsson <hp@axis.com>2005-01-28 03:28:40 +0000
commitf4f8cce440a38bf606aab597fd9ccb324f0fee87 (patch)
tree02023500e5418a27be53203106a172eb9ba73b13
parent99b2a78e3434fc29300cb219ba382466d4cf6714 (diff)
downloadgdb-f4f8cce440a38bf606aab597fd9ccb324f0fee87.zip
gdb-f4f8cce440a38bf606aab597fd9ccb324f0fee87.tar.gz
gdb-f4f8cce440a38bf606aab597fd9ccb324f0fee87.tar.bz2
* callback.c (default_callback): Initialize target_endian.
(cb_store_target_endian): Renamed from store, new first parameter host_callback *cb, drop last parameter big_p. Take endianness from cb. (cb_host_to_target_stat): Change to use cb_store_target_endian. Remove variable big_p. * nrun.c (main): Initialize default_callback.target_endian.
-rw-r--r--sim/common/ChangeLog10
-rw-r--r--sim/common/callback.c19
-rw-r--r--sim/common/nrun.c6
3 files changed, 27 insertions, 8 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 6bd7033..ea9e80b 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,13 @@
+2005-01-28 Hans-Peter Nilsson <hp@axis.com>
+
+ * callback.c (default_callback): Initialize target_endian.
+ (cb_store_target_endian): Renamed from store, new first parameter
+ host_callback *cb, drop last parameter big_p. Take endianness
+ from cb.
+ (cb_host_to_target_stat): Change to use cb_store_target_endian.
+ Remove variable big_p.
+ * nrun.c (main): Initialize default_callback.target_endian.
+
2005-01-14 Andrew Cagney <cagney@gnu.org>
* configure.ac: Replace SIM_AC_COMMON with sinclude of common.m4.
diff --git a/sim/common/callback.c b/sim/common/callback.c
index 7ba0c06..e0125c1 100644
--- a/sim/common/callback.c
+++ b/sim/common/callback.c
@@ -626,6 +626,9 @@ host_callback default_callback =
0, /* signal_map */
0, /* stat_map */
+ /* Defaults expected to be overridden at initialization, where needed. */
+ BFD_ENDIAN_UNKNOWN, /* target_endian */
+
HOST_CALLBACK_MAGIC,
};
@@ -757,17 +760,17 @@ cb_target_to_host_open (cb, target_val)
return host_val;
}
-/* Utility for cb_host_to_target_stat to store values in the target's
+/* Utility for e.g. cb_host_to_target_stat to store values in the target's
stat struct. */
-static void
-store (p, size, val, big_p)
+void
+cb_store_target_endian (cb, p, size, val)
+ host_callback *cb;
char *p;
int size;
long val; /* ??? must be as big as target word size */
- int big_p;
{
- if (big_p)
+ if (cb->target_endian == BFD_ENDIAN_BIG)
{
p += size;
while (size-- > 0)
@@ -801,7 +804,6 @@ cb_host_to_target_stat (cb, hs, ts)
{
const char *m = cb->stat_map;
char *p;
- int big_p = 0;
if (hs == NULL)
ts = NULL;
@@ -833,7 +835,7 @@ cb_host_to_target_stat (cb, hs, ts)
#undef ST_x
#define ST_x(FLD) \
else if (strncmp (m, #FLD, q - m) == 0) \
- store (p, size, hs->FLD, big_p)
+ cb_store_target_endian (cb, p, size, hs->FLD)
#ifdef HAVE_STRUCT_STAT_ST_DEV
ST_x (st_dev);
@@ -877,7 +879,8 @@ cb_host_to_target_stat (cb, hs, ts)
#undef ST_x
/* FIXME:wip */
else
- store (p, size, 0, big_p); /* unsupported field, store 0 */
+ /* Unsupported field, store 0. */
+ cb_store_target_endian (cb, p, size, 0);
}
p += size;
diff --git a/sim/common/nrun.c b/sim/common/nrun.c
index d0c43e6..ed1d1ea 100644
--- a/sim/common/nrun.c
+++ b/sim/common/nrun.c
@@ -82,6 +82,12 @@ main (int argc, char **argv)
abort ();
}
+ /* We can't set the endianness in the callback structure until
+ sim_config is called, which happens in sim_open. */
+ default_callback.target_endian
+ = (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN
+ ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE);
+
/* Was there a program to run? */
prog_argv = STATE_PROG_ARGV (sd);
prog_bfd = STATE_PROG_BFD (sd);