This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch]: fix psim / --disable-sim-inline lossage
- From: matthew green <mrg at cygnus dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 30 Dec 2001 21:52:44 +1100
- Subject: [patch]: fix psim / --disable-sim-inline lossage
- Organisation: Red Hat, Asia-Pacific.
this adds the missing functions to psim's bits.[ch], allowing sim-fpu.c
to link in regardless of the --enable-sim-inline setting. i looked at
having psim use common/sim-bits.[ch], but this requires using common/
sim-inline.h and sim-basics.h and that requires quite a lot of work so
i have not done this. at the very least, these changes only bring the
psim versions slightly closer to the sim-common versions. also included
is a small typo fix.
i've tested that this allows psim to run happily again both with and
without any --{en,dis}able-sim-inline setting.
OK?
.mrg.
2001-12-30 matthew green <mrg@redhat.com>
* bits.c (LSMASKED64): New inline function.
(LSEXTRACTED64): Likewise.
* bits.h (_LSB_POS, _LSMASKn, LSMASK64): New macros from
sim/common/sim-bits.h
(LSMASKED64, LSEXTRACTED64): New functions definitions.
* Makefile.in (sim-bits.o): Remove target.
* main.c (zalloc): Fix typoe in error message.
Index: bits.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/bits.c,v
retrieving revision 1.1.1.1
diff -p -r1.1.1.1 bits.c
*** bits.c 1999/04/16 01:35:08 1.1.1.1
--- bits.c 2001/12/30 10:52:32
***************
*** 24,30 ****
--- 24,50 ----
#include "basics.h"
+ INLINE_BITS\
+ (unsigned64)
+ LSMASKED64 (unsigned64 word,
+ int start,
+ int stop)
+ {
+ word &= LSMASK64 (start, stop);
+ return word;
+ }
+ INLINE_BITS\
+ (unsigned64)
+ LSEXTRACTED64 (unsigned64 val,
+ int start,
+ int stop)
+ {
+ val <<= (64 - 1 - start); /* drop high bits */
+ val >>= (64 - 1 - start) + (stop); /* drop low bits */
+ return val;
+ }
+
INLINE_BITS\
(unsigned32)
MASKED32(unsigned32 word,
Index: bits.h
===================================================================
RCS file: /cvs/src/src/sim/ppc/bits.h,v
retrieving revision 1.1.1.1
diff -p -r1.1.1.1 bits.h
*** bits.h 1999/04/16 01:35:08 1.1.1.1
--- bits.h 2001/12/30 10:52:32
***************
*** 45,54 ****
--- 45,59 ----
MASKED*(VALUE, FIRST, LAST): Masks out all but bits [FIRST
.. LAST].
+ LSMASKED*(VALUE, FIRST, LAST): Like MASKED - LS bit is zero.
+
EXTRACTED*(VALUE, FIRST, LAST): Masks out bits [FIRST .. LAST] but
also right shifts the masked value so that bit LAST becomes the
least significant (right most).
+ LSEXTRACTED*(VALUE, FIRST, LAST): Same as extracted - LS bit is
+ zero.
+
SHUFFLED**(VALUE, OLD, NEW): Mask then move a single bit from OLD
new NEW.
***************
*** 77,82 ****
--- 82,94 ----
#define _MAKE_SHIFT(WIDTH, pos) ((WIDTH) - 1 - (pos))
+ #if (WITH_TARGET_WORD_MSB == 0)
+ #define _LSB_POS(WIDTH, SHIFT) (WIDTH - 1 - SHIFT)
+ #else
+ #define _LSB_POS(WIDTH, SHIFT) (SHIFT)
+ #endif
+
+
/* MakeBit */
#define _BITn(WIDTH, pos) (((natural##WIDTH)(1)) \
<< _MAKE_SHIFT(WIDTH, pos))
***************
*** 104,109 ****
--- 116,129 ----
#define MASK32(START, STOP) _MASKn(32, START, STOP)
#define MASK64(START, STOP) _MASKn(64, START, STOP)
+ /* Multi-bit mask on least significant bits */
+
+ #define _LSMASKn(WIDTH, FIRST, LAST) _MASKn (WIDTH, \
+ _LSB_POS (WIDTH, FIRST), \
+ _LSB_POS (WIDTH, LAST))
+
+ #define LSMASK64(FIRST, LAST) _LSMASKn (64, (FIRST), (LAST))
+
#if (WITH_TARGET_WORD_BITSIZE == 64)
#define MASK(START, STOP) \
(((START) <= (STOP)) \
*************** INLINE_BITS\
*** 149,154 ****
--- 169,180 ----
unsigned start,
unsigned stop);
+ INLINE_BITS\
+ (unsigned64) LSMASKED64
+ (unsigned64 word,
+ int first,
+ int last);
+
/* extract the required bits aligning them with the lsb */
#define _EXTRACTEDn(WIDTH, WORD, START, STOP) \
*************** INLINE_BITS\
*** 165,170 ****
--- 191,201 ----
unsigned start,
unsigned stop);
+ INLINE_BITS\
+ (unsigned64) LSEXTRACTED64
+ (unsigned64 val,
+ int start,
+ int stop);
/* move a single bit around */
/* NB: the wierdness (N>O?N-O:0) is to stop a warning from GCC */
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/sim/ppc/Makefile.in,v
retrieving revision 1.3
diff -p -r1.3 Makefile.in
*** Makefile.in 2001/12/14 00:22:12 1.3
--- Makefile.in 2001/12/30 10:52:32
*************** targ-map.o: targ-map.c targ-vals.h
*** 429,437 ****
sim-fpu.o: $(srcdir)/../common/sim-fpu.c config.h tconfig.h
$(CC) -c $(STD_CFLAGS) -DHAVE_CONFIG_H $(srcdir)/../common/sim-fpu.c
- sim-bits.o: $(srcdir)/../common/sim-bits.c config.h tconfig.h
- $(CC) -c $(STD_CFLAGS) -DHAVE_CONFIG_H $(srcdir)/../common/sim-bits.c
-
tconfig.h:
rm -f tconfig.h
echo > tconfig.h
--- 429,434 ----
Index: main.c
===================================================================
RCS file: /cvs/src/src/sim/ppc/main.c,v
retrieving revision 1.2
diff -p -r1.2 main.c
*** main.c 2001/12/15 05:08:44 1.2
--- main.c 2001/12/30 10:52:33
*************** zalloc(long size)
*** 248,254 ****
{
void *memory = malloc(size);
if (memory == NULL)
! error("zmalloc failed\n");
memset(memory, 0, size);
return memory;
}
--- 248,254 ----
{
void *memory = malloc(size);
if (memory == NULL)
! error("zalloc failed\n");
memset(memory, 0, size);
return memory;
}