[llvm-commits] [PATCH, test-suite] Fix test cases for 64-bit big-endian platforms
Benjamin Kramer
benny.kra at gmail.com
Wed Oct 10 11:59:25 PDT 2012
On 10.10.2012, at 19:36, Ulrich Weigand <Ulrich.Weigand at de.ibm.com> wrote:
>
> 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?
patch LGTM!
- Ben
More information about the llvm-commits
mailing list