mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-23 03:29:47 +08:00
sim: tests: get common tests working again
These were written with 32-bit host assumptions baked into it. Simplify the printf formats to use ll length modifier as it's in C11 rather than trying to manually break it up into two, and cleanup some of the casts to stop assuming sizeof(long) is the same as sizeof(int). We also have to add a few more includes for the various funcs used in here. The tests aren't compiled automatically still. We can figure that out later with more work.
This commit is contained in:
@ -1,3 +1,18 @@
|
||||
2021-01-11 Mike Frysinger <vapier@gentoo.org>
|
||||
|
||||
* common/alu-tst.c: Include stdlib.h.
|
||||
(PACKAGE): Define.
|
||||
(print_hex): Change printf to use %llx.
|
||||
* common/bits-gen.c: Include stdlib.h, string.h, and unistd.h.
|
||||
(gen_struct): Change long long to unsigned64.
|
||||
(gen_bit): Change bit cast to bit mask. Change printf to use %llx.
|
||||
(gen_mask): Likewise.
|
||||
(usage): Delete default case.
|
||||
(main): Change WITH_HOST_WORD_BITSIZE printf from %d to %zu. Emit
|
||||
PACKAGE define and stdlib.h & string.h includes.
|
||||
* common/bits-tst.c (calc): Change printf to use %llx.
|
||||
(check_sext, check_rot, check_extract, check_bits): Likewise.
|
||||
|
||||
2021-01-09 Mike Frysinger <vapier@gentoo.org>
|
||||
|
||||
* configure: Regenerate.
|
||||
@ -368,4 +383,3 @@ Mon Sep 1 16:43:55 1997 Andrew Cagney <cagney@b1.cygnus.com>
|
||||
|
||||
* configure.in (configdirs): Test for the target directory instead
|
||||
of matching on a target.
|
||||
|
||||
|
@ -14,8 +14,11 @@
|
||||
|
||||
#define SIM_BITS_INLINE (INCLUDE_MODULE | INCLUDED_BY_MODULE)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define PACKAGE "sim"
|
||||
|
||||
#include "sim-basics.h"
|
||||
|
||||
#include "sim-alu.h"
|
||||
@ -62,9 +65,7 @@ print_hex (unsigned64 val, int nr_bits)
|
||||
printf ("0x%08lx", (long) (unsigned32) (val));
|
||||
break;
|
||||
case 64:
|
||||
printf ("0x%08lx%08lx",
|
||||
(long) (unsigned32) (val >> 32),
|
||||
(long) (unsigned32) (val));
|
||||
printf ("0x%016llx", (long long) (unsigned64) (val));
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
|
@ -17,9 +17,10 @@ GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void
|
||||
gen_struct (void)
|
||||
@ -29,8 +30,8 @@ gen_struct (void)
|
||||
printf (" int line;\n");
|
||||
printf (" int row;\n");
|
||||
printf (" int col;\n");
|
||||
printf (" long long val;\n");
|
||||
printf (" long long check;\n");
|
||||
printf (" unsigned64 val;\n");
|
||||
printf (" unsigned64 check;\n");
|
||||
printf ("} test_tuples;\n");
|
||||
printf ("\n");
|
||||
printf ("typedef struct _test_spec {\n");
|
||||
@ -62,13 +63,12 @@ gen_bit (int bitsize,
|
||||
else
|
||||
bit <<= i;
|
||||
if (bitsize == 32)
|
||||
bit = (unsigned) bit; /* truncate it! */
|
||||
bit &= 0xffffffff; /* truncate it! */
|
||||
/* write it out */
|
||||
printf (" { __LINE__, ");
|
||||
printf ("%d, %2d, ", -1, i);
|
||||
printf ("%s (%2d), ", macro, i);
|
||||
printf ("UNSIGNED64 (0x%08lx%08lx), ",
|
||||
(long) (bit >> 32), (long) bit);
|
||||
printf ("UNSIGNED64 (0x%016llx), ", bit);
|
||||
printf ("},\n");
|
||||
}
|
||||
printf ("};\n");
|
||||
@ -141,11 +141,10 @@ gen_mask (int bitsize,
|
||||
mask |= bit;
|
||||
}
|
||||
if (bitsize == 32)
|
||||
mask = (unsigned long) mask;
|
||||
mask &= 0xffffffff;
|
||||
printf ("%d, %d, ", l, h);
|
||||
printf ("%s%s (%2d, %2d), ", msb, macro, l, h);
|
||||
printf ("UNSIGNED64 (0x%08lx%08lx), ",
|
||||
(long) (mask >> 32), (long) mask);
|
||||
printf ("UNSIGNED64 (0x%llx), ", mask);
|
||||
}
|
||||
else
|
||||
printf ("-1, -1, ");
|
||||
@ -184,7 +183,6 @@ usage (int reason)
|
||||
case 4:
|
||||
fprintf (stderr, "Invalid <byte-order> argument\n");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
exit (1);
|
||||
@ -232,13 +230,16 @@ main (int argc, char *argv[])
|
||||
|
||||
printf ("#define WITH_TARGET_WORD_BITSIZE %d\n", bitsize);
|
||||
printf ("#define WITH_TARGET_WORD_MSB %d\n", msb);
|
||||
printf ("#define WITH_HOST_WORD_BITSIZE %d\n", sizeof (int) * 8);
|
||||
printf ("#define WITH_HOST_WORD_BITSIZE %zu\n", sizeof (int) * 8);
|
||||
printf ("#define WITH_TARGET_BYTE_ORDER %s\n", big_endian ? "BFD_ENDIAN_BIG" : "BFD_ENDIAN_LITTLE");
|
||||
printf ("\n");
|
||||
printf ("#define SIM_BITS_INLINE (ALL_H_INLINE)\n");
|
||||
printf ("\n");
|
||||
printf ("#define ASSERT(X) do { if (!(X)) abort(); } while (0)\n");
|
||||
printf ("\n");
|
||||
printf ("#define PACKAGE \"sim\"\n");
|
||||
printf ("#include <stdlib.h>\n");
|
||||
printf ("#include <string.h>\n");
|
||||
printf ("#include \"sim-basics.h\"\n");
|
||||
|
||||
gen_struct ();
|
||||
|
@ -153,8 +153,8 @@ calc (const char *call,
|
||||
else
|
||||
{
|
||||
fprintf (stderr,
|
||||
"Unknown call passed to calc (%s, 0x%08lx%08lx, %d, %d)\n",
|
||||
call, (long)(val >> 32), (long)val, row, col);
|
||||
"Unknown call passed to calc (%s, 0x%016llx, %d, %d)\n",
|
||||
call, val, row, col);
|
||||
abort ();
|
||||
return val;
|
||||
}
|
||||
@ -185,10 +185,8 @@ check_sext (int nr_bits,
|
||||
fprintf (stderr,
|
||||
"%s:%d: ", __FILE__, __LINE__);
|
||||
fprintf (stderr,
|
||||
" %s(0x%08lx%08lx,%d) == 0x%08lx%08lx wrong, != 0x%08lx%08lx\n",
|
||||
sexted, (long)(mask_0 >> 32), (long)mask_0, col,
|
||||
(long)(sext_0 >> 32), (long)sext_0,
|
||||
(long)(mask_1 >> 32), (long)mask_1);
|
||||
" %s(0x%016llx,%d) == 0x%016llx wrong, != 0x%016llx\n",
|
||||
sexted, mask_0, col, sext_0, mask_1);
|
||||
errors ++;
|
||||
}
|
||||
if (sext_1 != mask_1)
|
||||
@ -196,10 +194,8 @@ check_sext (int nr_bits,
|
||||
fprintf (stderr,
|
||||
"%s:%d: ", __FILE__, __LINE__);
|
||||
fprintf (stderr,
|
||||
" %s(0x%08lx%08lx,%d) == 0x%08lx%08lx wrong, != 0x%08lx%08lx\n",
|
||||
sexted, (long)(mask_1 >> 32), (long)mask_1, col,
|
||||
(long)(sext_1 >> 32), (long)sext_1,
|
||||
(long)(mask_1 >> 32), (long)mask_1);
|
||||
" %s(0x%016llx,%d) == 0x%016llx wrong, != 0x%016llx\n",
|
||||
sexted, mask_1, col, sext_1, mask_1);
|
||||
errors ++;
|
||||
}
|
||||
if (sext != msmask)
|
||||
@ -207,10 +203,8 @@ check_sext (int nr_bits,
|
||||
fprintf (stderr,
|
||||
"%s:%d: ", __FILE__, __LINE__);
|
||||
fprintf (stderr,
|
||||
" %s(0x%08lx%08lx,%d) == 0x%08lx%08lx wrong, != 0x%08lx%08lx (%s(%d,%d))\n",
|
||||
sexted, (long)(mask >> 32), (long)mask, col,
|
||||
(long)(sext >> 32), (long)sext,
|
||||
(long)(msmask >> 32), (long)msmask,
|
||||
" %s(0x%016llx,%d) == 0x%016llx wrong, != 0x%016llx (%s(%d,%d))\n",
|
||||
sexted, mask, col, sext, msmask,
|
||||
msmasked, 0, (msb_nr ? nr_bits - col - 1 : col));
|
||||
errors ++;
|
||||
}
|
||||
@ -244,10 +238,8 @@ check_rot (int nr_bits,
|
||||
|| (shift != 0 && rot == mask && abs(row - col) != (nr_bits - 1)))
|
||||
{
|
||||
fprintf (stderr, "%s:%d: ", __FILE__, __LINE__);
|
||||
fprintf (stderr, " %s(%s(0x%08lx%08lx,%d) == 0x%08lx%08lx, %d) failed\n",
|
||||
roted, roted,
|
||||
(long)(mask >> 32), (long)mask, shift,
|
||||
(long)(urot >> 32), (long)urot, -shift);
|
||||
fprintf (stderr, " %s(%s(0x%016llx,%d) == 0x%016llx, %d) failed\n",
|
||||
roted, roted, mask, shift, urot, -shift);
|
||||
errors ++;
|
||||
}
|
||||
}
|
||||
@ -276,10 +268,8 @@ check_extract (int nr_bits,
|
||||
if (mask != inst)
|
||||
{
|
||||
fprintf (stderr, "%s:%d: ", __FILE__, __LINE__);
|
||||
fprintf (stderr, " %s(%d,%d)=0x%08lx%08lx -> %s=0x%08lx%08lx -> %s=0x%08lx%08lx failed\n",
|
||||
masked, row, col, (long)(mask >> 32), (long)mask,
|
||||
extracted, (long)(extr >> 32), (long)extr,
|
||||
inserted, (long)(inst >> 32), (long)inst);
|
||||
fprintf (stderr, " %s(%d,%d)=0x%016llx -> %s=0x%016llx -> %s=0x%016llx failed\n",
|
||||
masked, row, col, mask, extracted, extr, inserted, inst);
|
||||
errors ++;
|
||||
}
|
||||
}
|
||||
@ -317,9 +307,8 @@ check_bits (int call,
|
||||
fprintf (stderr, " (%d, %d)", tuple->row, tuple->col);
|
||||
else
|
||||
fprintf (stderr, " (%d)", tuple->col);
|
||||
fprintf (stderr, " == 0x%08lx%08lx wrong, != 0x%08lx%08lx\n",
|
||||
(long) (val >> 32), (long) val,
|
||||
(long) (check >> 32), (long) check);
|
||||
fprintf (stderr, " == 0x%016llx wrong, != 0x%016llx\n",
|
||||
val, check);
|
||||
errors ++;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user