[llvm-commits] [PATCH, test-suite] Fix test cases for 64-bit big-endian platforms

Ulrich Weigand Ulrich.Weigand at de.ibm.com
Wed Oct 10 10:36:14 PDT 2012


Hello,

a couple of tests fail simply because the code is not
safe on 64-bit big-endian platforms.

In MultiSource/Applications/viterbi, the read_dmatrix
routine uses scanf with a "%d" specifier to read into
a "size_t" variable -- this breaks when size_t is 64-bit
(may happen to work on little-endian, but never on
big-endian platforms).

In MultiSource/Benchmarks/MiBench/consumer-lame, the
DetermineByteOrder routine has an implicit assumption
that "long" is a 4-byte data type; again, it happens to
still work on a 64-bit little-endian system but breaks
on a big-endian system.

The appended patch fixes both problems, and both
tests now pass on PowerPC.  For viterbi, the patch
simply uses "int" instead of "size_t".  For consumer-lame,
the patch also just uses "int" instead of "long" -- this of
course still has an assumption that "int" is a 4-byte type,
but that's probably always true on systems where lame
runs in the first place.  (If not, we can find a more generic
way to determine endianness.  I just wanted to keep
changes to the benchmark sources as small as possible.)

OK to commit?

Bye,
Ulrich

(See attached file: diff-testsuite-be64bit)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diff-testsuite-be64bit
Type: application/octet-stream
Size: 1478 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121010/debe33dd/attachment.obj>


More information about the llvm-commits mailing list