Passify GCC. Convert 0x0LL to something more portable in the FP code.

This commit is contained in:
Andrew Cagney 1997-08-30 00:02:19 +00:00
parent 4113ba4cd7
commit f90b720ba1
9 changed files with 311 additions and 141 deletions

View file

@ -1,3 +1,27 @@
Sat Aug 30 09:47:21 1997 Andrew Cagney <cagney@b1.cygnus.com>
* sim-fpu.c (DP_GARDMSB, ...): Make unsigned.
(DP_FRACHIGH, DP_FRACHIGH2, ..): Use MSMASK to avoid LL.
Fri Aug 29 13:37:44 1997 Andrew Cagney <cagney@b1.cygnus.com>
* sim-core.c (sim_core_map_attach): Cast attach enum to int.
(sim_core_xor_read_buffer, sim_core_xor_write_buffer): Make
nr_transfered and nr_this_transfer unsigned.
* sim-events.c (sim_events_tickn): N is signed, as limited to
MAXINT.
* sim-n-endian.h (offset_N): Change size to unsigned.
* callback.c (os_poll_quit): Add prototypes for kbhit and getkey.
Fri Aug 29 10:10:53 1997 Andrew Cagney <cagney@b1.cygnus.com>
* sim-utils.c (sim_copy_argv): Delete, replaced by dupargv.
* sim-options.c (sim_parse_args): Use dupargv.
Thu Aug 28 10:36:34 1997 Doug Evans <dje@canuck.cygnus.com>
* sim-options.c (standard_option_handler): Use xstrdup, not strdup.

View file

@ -44,6 +44,12 @@
#include <unistd.h>
#endif
/* ??? sim_cb_printf should be cb_printf, but until the callback support is
broken out of the simulator directory, these are here to not require
sim-utils.h. */
void sim_cb_printf PARAMS ((host_callback *, const char *, ...));
void sim_cb_eprintf PARAMS ((host_callback *, const char *, ...));
extern int system PARAMS ((const char *));
static int os_init PARAMS ((host_callback *));
@ -133,6 +139,8 @@ os_poll_quit (p)
host_callback *p;
{
#ifndef _MSC_VER
int kbhit ();
int getkey ();
if (kbhit ())
{
int k = getkey ();

View file

@ -59,13 +59,11 @@ STATIC_SIM_CORE\
(SIM_RC)
sim_core_init (SIM_DESC sd)
{
sim_core *memory = STATE_CORE(sd);
sim_core *core = STATE_CORE(sd);
sim_core_maps map;
for (map = 0;
map < nr_sim_core_maps;
map++) {
for (map = 0; map < nr_sim_core_maps; map++) {
/* blow away old mappings */
sim_core_mapping *curr = memory->map[map].first;
sim_core_mapping *curr = core->common.map[map].first;
while (curr != NULL) {
sim_core_mapping *tbd = curr;
curr = curr->next;
@ -75,7 +73,21 @@ sim_core_init (SIM_DESC sd)
}
zfree(tbd);
}
memory->map[map].first = NULL;
core->common.map[map].first = NULL;
}
core->byte_xor = 0;
/* Just copy this map to each of the processor specific data structures.
FIXME - later this will be replaced by true processor specific
maps. */
{
int i;
for (i = 0; i < MAX_NR_PROCESSORS; i++)
{
int j;
CPU_CORE (STATE_CPU (sd, i))->common = STATE_CORE (sd)->common;
for (j = 0; j < WITH_XOR_ENDIAN; j++)
CPU_CORE (STATE_CPU (sd, i))->xor [j] = 0;
}
}
return SIM_RC_OK;
}
@ -195,8 +207,8 @@ sim_core_map_attach(SIM_DESC sd,
next_mapping = access_map->first;
last_mapping = &access_map->first;
while(next_mapping != NULL
&& (next_mapping->level < attach
|| (next_mapping->level == attach
&& (next_mapping->level < (int) attach
|| (next_mapping->level == (int) attach
&& next_mapping->bound < addr))) {
/* provided levels are the same */
/* assert: next_mapping->base > all bases before next_mapping */
@ -206,8 +218,8 @@ sim_core_map_attach(SIM_DESC sd,
}
/* check insertion point correct */
SIM_ASSERT(next_mapping == NULL || next_mapping->level >= attach);
if (next_mapping != NULL && next_mapping->level == attach
SIM_ASSERT (next_mapping == NULL || next_mapping->level >= (int) attach);
if (next_mapping != NULL && next_mapping->level == (int) attach
&& next_mapping->base < (addr + (nr_bytes - 1))) {
#if (WITH_DEVICES)
device_error(client, "map overlap when attaching %d:0x%lx (%ld)",
@ -243,7 +255,6 @@ sim_core_attach(SIM_DESC sd,
sim_core_maps map;
void *buffer;
int buffer_freed;
int i;
/* check for for attempt to use unimplemented per-processor core map */
if (cpu != NULL)
@ -288,15 +299,15 @@ sim_core_attach(SIM_DESC sd,
switch (map) {
case sim_core_read_map:
if (access & access_read)
sim_core_map_attach(sd, &memory->map[map],
attach,
space, addr, nr_bytes,
client, buffer, !buffer_freed);
sim_core_map_attach(sd, &memory->common.map[map],
attach,
space, addr, nr_bytes,
client, buffer, !buffer_freed);
buffer_freed ++;
break;
case sim_core_write_map:
if (access & access_write)
sim_core_map_attach(sd, &memory->map[map],
sim_core_map_attach(sd, &memory->common.map[map],
attach,
space, addr, nr_bytes,
client, buffer, !buffer_freed);
@ -304,7 +315,7 @@ sim_core_attach(SIM_DESC sd,
break;
case sim_core_execute_map:
if (access & access_exec)
sim_core_map_attach(sd, &memory->map[map],
sim_core_map_attach(sd, &memory->common.map[map],
attach,
space, addr, nr_bytes,
client, buffer, !buffer_freed);
@ -319,16 +330,19 @@ sim_core_attach(SIM_DESC sd,
/* Just copy this map to each of the processor specific data structures.
FIXME - later this will be replaced by true processor specific
maps. */
for (i = 0; i < MAX_NR_PROCESSORS; i++)
{
CPU_CORE (STATE_CPU (sd, i))->common = *STATE_CORE (sd);
}
{
int i;
for (i = 0; i < MAX_NR_PROCESSORS; i++)
{
CPU_CORE (STATE_CPU (sd, i))->common = STATE_CORE (sd)->common;
}
}
}
STATIC_INLINE_SIM_CORE\
(sim_core_mapping *)
sim_core_find_mapping(sim_core *core,
sim_core_find_mapping(sim_core_common *core,
sim_core_maps map,
address_word addr,
unsigned nr_bytes,
@ -359,8 +373,8 @@ sim_core_find_mapping(sim_core *core,
STATIC_INLINE_SIM_CORE\
(void *)
sim_core_translate(sim_core_mapping *mapping,
address_word addr)
sim_core_translate (sim_core_mapping *mapping,
address_word addr)
{
return (void *)(((char *)mapping->buffer) + addr - mapping->base);
}
@ -368,20 +382,22 @@ sim_core_translate(sim_core_mapping *mapping,
EXTERN_SIM_CORE\
(unsigned)
sim_core_read_buffer(SIM_DESC sd,
sim_core_maps map,
void *buffer,
address_word addr,
unsigned len)
sim_core_read_buffer (SIM_DESC sd,
sim_cpu *cpu,
sim_core_maps map,
void *buffer,
address_word addr,
unsigned len)
{
sim_core_common *core = (cpu == NULL ? &STATE_CORE (sd)->common : &CPU_CORE (cpu)->common);
unsigned count = 0;
while (count < len) {
unsigned_word raddr = addr + count;
sim_core_mapping *mapping =
sim_core_find_mapping(STATE_CORE (sd), map,
sim_core_find_mapping(core, map,
raddr, /*nr-bytes*/1,
read_transfer,
0, NULL, NULL_CIA); /*dont-abort*/
0 /*dont-abort*/, NULL, NULL_CIA);
if (mapping == NULL)
break;
#if (WITH_DEVICES)
@ -411,19 +427,22 @@ sim_core_read_buffer(SIM_DESC sd,
EXTERN_SIM_CORE\
(unsigned)
sim_core_write_buffer(SIM_DESC sd,
sim_core_maps map,
const void *buffer,
address_word addr,
unsigned len)
sim_core_write_buffer (SIM_DESC sd,
sim_cpu *cpu,
sim_core_maps map,
const void *buffer,
address_word addr,
unsigned len)
{
sim_core_common *core = (cpu == NULL ? &STATE_CORE (sd)->common : &CPU_CORE (cpu)->common);
unsigned count = 0;
while (count < len) {
unsigned_word raddr = addr + count;
sim_core_mapping *mapping = sim_core_find_mapping(STATE_CORE (sd), map,
raddr, /*nr-bytes*/1,
write_transfer,
0, NULL, NULL_CIA); /*dont-abort*/
sim_core_mapping *mapping =
sim_core_find_mapping(core, map,
raddr, /*nr-bytes*/1,
write_transfer,
0 /*dont-abort*/, NULL, NULL_CIA);
if (mapping == NULL)
break;
#if (WITH_DEVICES)
@ -454,35 +473,160 @@ sim_core_write_buffer(SIM_DESC sd,
EXTERN_SIM_CORE\
(void)
sim_core_set_xor (sim_cpu *cpu,
sim_cia cia,
sim_core_set_xor (SIM_DESC sd,
sim_cpu *cpu,
int is_xor)
{
sim_cpu_core *cpu_core = CPU_CORE (cpu);
/* set up the XOR registers if required. */
/* set up the XOR map if required. */
if (WITH_XOR_ENDIAN) {
{
int i = 1;
unsigned mask;
if (is_xor)
mask = WITH_XOR_ENDIAN - 1;
else
mask = 0;
while (i - 1 < WITH_XOR_ENDIAN)
sim_core *core = STATE_CORE (sd);
sim_cpu_core *cpu_core = (cpu != NULL ? CPU_CORE (cpu) : NULL);
if (cpu_core != NULL)
{
cpu_core->xor[i-1] = mask;
mask = (mask << 1) & (WITH_XOR_ENDIAN - 1);
i = (i << 1);
int i = 1;
unsigned mask;
if (is_xor)
mask = WITH_XOR_ENDIAN - 1;
else
mask = 0;
while (i - 1 < WITH_XOR_ENDIAN)
{
cpu_core->xor[i-1] = mask;
mask = (mask << 1) & (WITH_XOR_ENDIAN - 1);
i = (i << 1);
}
}
else
{
if (is_xor)
core->byte_xor = WITH_XOR_ENDIAN - 1;
else
core->byte_xor = 0;
}
}
}
else {
if (is_xor)
sim_engine_abort (CPU_STATE (cpu), cpu, cia,
sim_engine_abort (sd, cpu, NULL_CIA,
"Attempted to enable xor-endian mode when permenantly disabled.");
}
}
STATIC_INLINE_SIM_CORE\
(void)
reverse_n (unsigned_1 *dest,
const unsigned_1 *src,
int nr_bytes)
{
int i;
for (i = 0; i < nr_bytes; i++)
{
dest [nr_bytes - i - 1] = src [i];
}
}
EXTERN_SIM_CORE\
(unsigned)
sim_core_xor_read_buffer (SIM_DESC sd,
sim_cpu *cpu,
sim_core_maps map,
void *buffer,
address_word addr,
unsigned nr_bytes)
{
address_word byte_xor = (cpu == NULL ? STATE_CORE (sd)->byte_xor : CPU_CORE (cpu)->xor[0]);
if (!WITH_XOR_ENDIAN || !byte_xor)
return sim_core_read_buffer (sd, cpu, map, buffer, addr, nr_bytes);
else
/* only break up transfers when xor-endian is both selected and enabled */
{
unsigned_1 x[WITH_XOR_ENDIAN];
unsigned nr_transfered = 0;
address_word start = addr;
unsigned nr_this_transfer = (WITH_XOR_ENDIAN - (addr & ~(WITH_XOR_ENDIAN - 1)));
address_word stop;
/* initial and intermediate transfers are broken when they cross
an XOR endian boundary */
while (nr_transfered + nr_this_transfer < nr_bytes)
/* initial/intermediate transfers */
{
/* since xor-endian is enabled stop^xor defines the start
address of the transfer */
stop = start + nr_this_transfer - 1;
SIM_ASSERT (start <= stop);
SIM_ASSERT ((stop ^ byte_xor) <= (start ^ byte_xor));
if (sim_core_read_buffer (sd, cpu, map, x, stop ^ byte_xor, nr_this_transfer)
!= nr_this_transfer)
return nr_transfered;
reverse_n (&((unsigned_1*)buffer)[nr_transfered], x, nr_this_transfer);
nr_transfered += nr_this_transfer;
nr_this_transfer = WITH_XOR_ENDIAN;
start = stop + 1;
}
/* final transfer */
nr_this_transfer = nr_bytes - nr_transfered;
stop = start + nr_this_transfer - 1;
SIM_ASSERT (stop == (addr + nr_bytes - 1));
if (sim_core_read_buffer (sd, cpu, map, x, stop ^ byte_xor, nr_this_transfer)
!= nr_this_transfer)
return nr_transfered;
reverse_n (&((unsigned_1*)buffer)[nr_transfered], x, nr_this_transfer);
return nr_bytes;
}
}
EXTERN_SIM_CORE\
(unsigned)
sim_core_xor_write_buffer (SIM_DESC sd,
sim_cpu *cpu,
sim_core_maps map,
const void *buffer,
address_word addr,
unsigned nr_bytes)
{
address_word byte_xor = (cpu == NULL ? STATE_CORE (sd)->byte_xor : CPU_CORE (cpu)->xor[0]);
if (!WITH_XOR_ENDIAN || !byte_xor)
return sim_core_write_buffer (sd, cpu, map, buffer, addr, nr_bytes);
else
/* only break up transfers when xor-endian is both selected and enabled */
{
unsigned_1 x[WITH_XOR_ENDIAN];
unsigned nr_transfered = 0;
address_word start = addr;
unsigned nr_this_transfer = (WITH_XOR_ENDIAN - (addr & ~(WITH_XOR_ENDIAN - 1)));
address_word stop;
/* initial and intermediate transfers are broken when they cross
an XOR endian boundary */
while (nr_transfered + nr_this_transfer < nr_bytes)
/* initial/intermediate transfers */
{
/* since xor-endian is enabled stop^xor defines the start
address of the transfer */
stop = start + nr_this_transfer - 1;
SIM_ASSERT (start <= stop);
SIM_ASSERT ((stop ^ byte_xor) <= (start ^ byte_xor));
reverse_n (x, &((unsigned_1*)buffer)[nr_transfered], nr_this_transfer);
if (sim_core_read_buffer (sd, cpu, map, x, stop ^ byte_xor, nr_this_transfer)
!= nr_this_transfer)
return nr_transfered;
nr_transfered += nr_this_transfer;
nr_this_transfer = WITH_XOR_ENDIAN;
start = stop + 1;
}
/* final transfer */
nr_this_transfer = nr_bytes - nr_transfered;
stop = start + nr_this_transfer - 1;
SIM_ASSERT (stop == (addr + nr_bytes - 1));
reverse_n (x, &((unsigned_1*)buffer)[nr_transfered], nr_this_transfer);
if (sim_core_read_buffer (sd, cpu, map, x, stop ^ byte_xor, nr_this_transfer)
!= nr_this_transfer)
return nr_transfered;
return nr_bytes;
}
}

View file

@ -410,7 +410,7 @@ sim_events_schedule_after_signal (SIM_DESC sd,
/* allocate an event entry from the signal buffer */
new_event = &events->held [events->nr_held];
events->nr_held ++;
if (events->nr_held >= MAX_NR_SIGNAL_SIM_EVENTS)
if (events->nr_held > MAX_NR_SIGNAL_SIM_EVENTS)
{
sim_engine_abort (NULL, NULL, NULL_CIA,
"sim_events_schedule_after_signal - buffer oveflow");
@ -864,7 +864,7 @@ sim_events_tick (SIM_DESC sd)
INLINE_SIM_EVENTS\
(int)
sim_events_tickn (SIM_DESC sd,
unsigned n)
int n)
{
sim_events *events = STATE_EVENTS (sd);

View file

@ -153,8 +153,9 @@ EXTERN_SIM_EVENTS\
void *data);
/* Schedule an event when the NR_BYTES value at HOST_ADDR with
BYTE_ORDER lies within LB..UB (unsigned).
/* Schedule an event when the test (IS_WITHIN == (VAL >= LB && VAL <=
UB)) of the NR_BYTES value at HOST_ADDR with BYTE_ORDER endian is
true.
HOST_ADDR: pointer into the host address space.
BYTE_ORDER: 0 - host endian; BIG_ENDIAN; LITTLE_ENDIAN */
@ -165,14 +166,16 @@ EXTERN_SIM_EVENTS\
void *host_addr,
int nr_bytes,
int byte_order,
int is_within,
unsigned64 lb,
unsigned64 ub,
sim_event_handler *handler,
void *data);
/* Schedule an event when the NR_BYTES value at CORE_ADDR with BYTE_ORDER
lies between LB..UB.
/* Schedule an event when the test (IS_WITHIN == (VAL >= LB && VAL <=
UB)) of the NR_BYTES value at CORE_ADDR in BYTE_ORDER endian is
true.
CORE_ADDR/MAP: pointer into the target address space.
BYTE_ORDER: 0 - current target endian; BIG_ENDIAN; LITTLE_ENDIAN */
@ -184,6 +187,7 @@ EXTERN_SIM_EVENTS\
sim_core_maps core_map,
int nr_bytes,
int byte_order,
int is_within,
unsigned64 lb,
unsigned64 ub,
sim_event_handler *handler,
@ -216,7 +220,7 @@ INLINE_SIM_EVENTS\
/* Progress time - separated into two parts so that the main loop can
save its context before the event queue is processed.
sim_events_tickn advances the clock by N cycles. */
sim_events_tickn advances the clock by N cycles (1..MAXINT) */
INLINE_SIM_EVENTS\
(int) sim_events_tick
@ -225,7 +229,7 @@ INLINE_SIM_EVENTS\
INLINE_SIM_EVENTS\
(int) sim_events_tickn
(SIM_DESC sd,
unsigned n);
int n);
INLINE_SIM_EVENTS\
(void) sim_events_process

View file

@ -1,23 +1,44 @@
/* Simulator Floating-point support.
Copyright (C) 1994, 1997 Free Software Foundation, Inc.
Contributed by Cygnus Support.
/* This is a software floating point library which can be used instead of
the floating point routines in libgcc1.c for targets without hardware
floating point. */
This file is part of GDB, the GNU debugger.
/* Copyright (C) 1994,1997 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This file is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file with other programs, and to distribute
those programs without any restriction coming from the use of this
file. (The General Public License restrictions do apply in other
respects; for example, they cover modification of the file, and
distribution when not linked into another program.)
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* As a special exception, if you link this library with other files,
some of which are compiled with GCC, to produce an executable,
this library does not by itself cause the resulting executable
to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */
/* This implements IEEE 754 format arithmetic, but does not provide a
mechanism for setting the rounding mode, or for generating or handling
exceptions.
The original code by Steve Chamberlain, hacked by Mark Eichin and Jim
Wilson, all of Cygnus Support. */
#ifndef SIM_FPU_C
@ -34,12 +55,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define SP_NGARDS 7L
#define SP_GARDROUND 0x3f
#define SP_GARDMASK 0x7f
#define SP_GARDMSB 0x40
#define SP_GARDMASK ((unsigned) 0x7f)
#define SP_GARDMSB ((unsigned) 0x40)
#define SP_EXPBITS 8
#define SP_EXPBIAS 127
#define SP_FRACBITS 23
#define SP_EXPMAX (0xff)
#define SP_EXPMAX ((unsigned) 0xff)
#define SP_QUIET_NAN 0x100000L
#define SP_FRAC_NBITS 32
#define SP_FRACHIGH 0x80000000L
@ -47,23 +68,23 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define DP_NGARDS 8L
#define DP_GARDROUND 0x7f
#define DP_GARDMASK 0xff
#define DP_GARDMSB 0x80
#define DP_GARDMASK ((unsigned) 0xff)
#define DP_GARDMSB ((unsigned) 0x80)
#define DP_EXPBITS 11
#define DP_EXPBIAS 1023
#define DP_FRACBITS 52
#define DP_EXPMAX (0x7ff)
#define DP_QUIET_NAN 0x8000000000000LL
#define DP_EXPMAX ((unsigned) 0x7ff)
#define DP_QUIET_NAN MSBIT64 (12) /* 0x0008000000000000LL */
#define DP_FRAC_NBITS 64
#define DP_FRACHIGH 0x8000000000000000LL
#define DP_FRACHIGH2 0xc000000000000000LL
#define DP_FRACHIGH MSMASK64 (1) /* 0x8000000000000000LL */
#define DP_FRACHIGH2 MSMASK64 (2) /* 0xc000000000000000LL */
#define EXPMAX (is_double ? DP_EXPMAX : SP_EXPMAX)
#define EXPBITS (is_double ? DP_EXPBITS : SP_EXPBITS)
#define EXPBIAS (is_double ? DP_EXPBIAS : SP_EXPBIAS)
#define FRACBITS (is_double ? DP_FRACBITS : SP_FRACBITS)
#define NGARDS (is_double ? DP_NGARDS : (SP_NGARDS ))
#define SIGNBIT (1LL << (EXPBITS + FRACBITS))
#define SIGNBIT ((unsigned64)1 << (EXPBITS + FRACBITS))
#define FRAC_NBITS (is_double ? DP_FRAC_NBITS : SP_FRAC_NBITS)
#define GARDMASK (is_double ? DP_GARDMASK : SP_GARDMASK)
#define GARDMSB (is_double ? DP_GARDMSB : SP_GARDMSB)
@ -82,8 +103,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define NORMAL_EXPMIN (-(EXPBIAS)+1)
#define IMPLICIT_1 (1LL<<(FRACBITS+NGARDS))
#define IMPLICIT_2 (1LL<<(FRACBITS+1+NGARDS))
#define IMPLICIT_1 ((unsigned64)1 << (FRACBITS+NGARDS))
#define IMPLICIT_2 ((unsigned64)1 << (FRACBITS+1+NGARDS))
#define MAX_SI_INT (is_double ? LSMASK64 (63) : LSMASK64 (31))
#define MAX_USI_INT (is_double ? LSMASK64 (64) : LSMASK64 (32))
@ -300,6 +321,7 @@ fpu2ufpu (const sim_fpu *d)
return ans;
}
#if 0
STATIC_INLINE_SIM_FPU (int)
is_ufpu_number (const sim_ufpu *d)
{
@ -312,6 +334,7 @@ is_ufpu_number (const sim_ufpu *d)
return 0;
}
}
#endif
STATIC_INLINE_SIM_FPU (int)

View file

@ -23,6 +23,8 @@
#error "N must be #defined"
#endif
#include "sim-xcat.h"
/* NOTE: See end of file for #undef */
#define unsigned_N XCONCAT2(unsigned_,N)
#define endian_t2h_N XCONCAT2(endian_t2h_,N)
@ -126,22 +128,24 @@ endian_le2h_N(unsigned_N raw_in)
INLINE_SIM_ENDIAN\
(void*)
offset_N(unsigned_N *x,
int sizeof_word,
int word)
offset_N (unsigned_N *x,
unsigned sizeof_word,
unsigned word)
{
char *in = (char*)x;
char *out;
int offset = sizeof_word * word;
ASSERT(offset + sizeof_word <= sizeof(unsigned_N));
ASSERT(word < (sizeof_word / sizeof(unsigned_N)));
ASSERT((sizeof(unsigned_N) % sizeof_word) == 0);
if (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN) {
out = in + sizeof(unsigned_N) - offset;
}
else {
out = in + offset;
}
unsigned offset = sizeof_word * word;
ASSERT (offset + sizeof_word <= sizeof(unsigned_N));
ASSERT (word < (sizeof (unsigned_N) / sizeof_word));
ASSERT ((sizeof (unsigned_N) % sizeof_word) == 0);
if (WITH_HOST_BYTE_ORDER == LITTLE_ENDIAN)
{
out = in + sizeof (unsigned_N) - offset - sizeof_word;
}
else
{
out = in + offset;
}
return out;
}

View file

@ -405,7 +405,7 @@ sim_parse_args (sd, argv)
if (optc == -1)
{
if (STATE_OPEN_KIND (sd) == SIM_OPEN_STANDALONE)
STATE_PROG_ARGV (sd) = sim_copy_argv (argv + optind);
STATE_PROG_ARGV (sd) = dupargv (argv + optind);
break;
}
if (optc == '?')

View file

@ -110,43 +110,6 @@ sim_add_commas (char *buf, int sizeof_buf, unsigned long value)
return endbuf;
}
/* Make a copy of ARGV.
This can also be used to copy the environment vector.
The result is a pointer to the malloc'd copy or NULL if insufficient
memory available. */
char **
sim_copy_argv (argv)
char **argv;
{
int argc;
char **copy;
if (argv == NULL)
return NULL;
/* the vector */
for (argc = 0; argv[argc] != NULL; argc++);
copy = (char **) malloc ((argc + 1) * sizeof (char *));
if (copy == NULL)
return NULL;
/* the strings */
for (argc = 0; argv[argc] != NULL; argc++)
{
int len = strlen (argv[argc]);
copy[argc] = malloc (sizeof (char *) * (len + 1));
if (copy[argc] == NULL)
{
freeargv (copy);
return NULL;
}
strcpy (copy[argc], argv[argc]);
}
copy[argc] = NULL;
return copy;
}
/* Analyze a prog_name/prog_bfd and set various fields in the state
struct. */