Package: grfcodec
Version: 1.0.0+debian1-1
Severity: important
Tags: patch
Affects: openttd

grfcodec fails to properly work on at least s390 as can be seen in the
buildlog of OpenTTD 1.0.4~rc1-1 [1].

On powerpc grfcodec it works correctly meaning the problem is in the actual detection of endianness at compile time. For powerpc this works as grfcodec's source uses __BIG_ENDIAN__ to determine the endianness of the application, however s390 does not define __BIG_ENDIAN__ and thus grfcodec assumes it's little endian with this failure as result.

Attached is a patch which uses information provided by
(/usr/include/)endian.h to determine the endianness. This patch has been tested on amd64 and powerpc, but due to it not using __BIG_ENDIAN__ it should work on s390 as well.

[1]
https://buildd.debian.org/fetch.cgi?&pkg=openttd&ver=1.0.4%7Erc1-1&arch=s390&stamp=1283790653&file=log


-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (101, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages grfcodec depends on:
ii libc6 2.11.2-5 Embedded GNU C Library: Shared lib
ii  libgcc1                       1:4.5.1-2  GCC support library
ii  libstdc++6                    4.5.1-2    The GNU Standard C++ Library v3

grfcodec recommends no packages.

grfcodec suggests no packages.
diff -r 2f2e9551b542 src/typesize.h
--- a/src/typesize.h	Mon Sep 06 15:28:02 2010 +0200
+++ b/src/typesize.h	Wed Sep 08 05:51:13 2010 -0400
@@ -148,7 +148,8 @@
 	S8  s8[4];
 };
 
-#ifdef __BIG_ENDIAN__
+#include <endian.h>
+#if __BYTE_ORDER == __BIG_ENDIAN
 #	define BE_SWAP16(b) (*((U8*)(&b))+(*(((U8*)(&b))+1)<<8))
 #	define BE_SWAP32(b) (*((U8*)(&b))+(*(((U8*)(&b))+1)<<8)+(*(((U8*)(&b))+2)<<16)+(*(((U8*)(&b))+3)<<24))
 #	define BYTE_OFSL 1

Reply via email to