[openjk] 11/11: Add a patch to fix compilation on big-endian CPUs
Simon McVittie
smcv at debian.org
Sun Jan 22 10:23:06 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian/master
in repository openjk.
commit 30c2f00b583579eb284f18eb3e3e564f31602638
Author: Simon McVittie <smcv at debian.org>
Date: Sun Jan 22 10:10:19 2017 +0000
Add a patch to fix compilation on big-endian CPUs
---
debian/changelog | 1 +
debian/patches/series | 1 +
...d-failure-on-big-endian-CPUs-with-C-11-co.patch | 63 ++++++++++++++++++++++
3 files changed, 65 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 5563a32..5080800 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ openjk (0~20170122+dfsg1-1) UNRELEASED; urgency=medium
* New upstream snapshot
- Drop patches that were applied upstream
+ * Add a patch to fix compilation on big-endian CPUs
-- Simon McVittie <smcv at debian.org> Sun, 22 Jan 2017 10:08:02 +0000
diff --git a/debian/patches/series b/debian/patches/series
index 858ce4d..603a0f6 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
Pick-up-date-from-SOURCE_DATE_EPOCH-for-reproducible-buil.patch
g_utils-disarm-debug-code-that-writes-to-c-nofreeent.patch
+snd_mem-fix-build-failure-on-big-endian-CPUs-with-C-11-co.patch
diff --git a/debian/patches/snd_mem-fix-build-failure-on-big-endian-CPUs-with-C-11-co.patch b/debian/patches/snd_mem-fix-build-failure-on-big-endian-CPUs-with-C-11-co.patch
new file mode 100644
index 0000000..9bf58de
--- /dev/null
+++ b/debian/patches/snd_mem-fix-build-failure-on-big-endian-CPUs-with-C-11-co.patch
@@ -0,0 +1,63 @@
+From: Simon McVittie <smcv at debian.org>
+Date: Sat, 29 Oct 2016 13:07:04 +0100
+Subject: snd_mem: fix build failure on big-endian CPUs with C++11 compilers
+
+The Debian powerpc, mips and s390x builds failed with:
+
+.../code/client/snd_mem.cpp: In function 'qboolean S_LoadSound_Actual(sfx_t*)':
+.../code/client/snd_mem.cpp:843:54: error: invalid operands of types '__gnu_cxx::__enable_if<true, double>::__type {aka double}' and 'int' to binary 'operator>>'
+ if (sfx->fVolRange < (abs(sfx->pSoundData[i]) >> 8))
+ ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
+.../code/client/snd_mem.cpp:845:50: error: invalid operands of types '__gnu_cxx::__enable_if<true, double>::__type {aka double}' and 'int' to binary 'operator>>'
+ sfx->fVolRange = abs(sfx->pSoundData[i]) >> 8;
+ ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
+
+This appears to be because sfx->pSoundData[i] is of type short. C++98
+only provided int abs(int), long abs(long), float abs(float),
+double abs(double) and long double abs(long double) overloads, but
+C++11 also provides double abs(T) for all integral types T, including
+short. double is not a valid left-hand side for operator>> so
+compilation fails.
+
+Forwarded: https://github.com/JACoders/OpenJK/pull/886
+---
+ code/client/snd_mem.cpp | 6 ++++--
+ codemp/client/snd_mem.cpp | 6 ++++--
+ 2 files changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/code/client/snd_mem.cpp b/code/client/snd_mem.cpp
+index 821c8424..f2a003ed 100644
+--- a/code/client/snd_mem.cpp
++++ b/code/client/snd_mem.cpp
+@@ -840,9 +840,11 @@ static qboolean S_LoadSound_Actual( sfx_t *sfx )
+ for (int i = 0; i < sfx->iSoundLengthInSamples; i++)
+ {
+ sfx->pSoundData[i] = LittleShort(sfx->pSoundData[i]);
+- if (sfx->fVolRange < (abs(sfx->pSoundData[i]) >> 8))
++ // C++11 defines double abs(short) which is not what we want here,
++ // because double >> int is not defined. Force interpretation as int
++ if (sfx->fVolRange < (abs(static_cast<int>(sfx->pSoundData[i])) >> 8))
+ {
+- sfx->fVolRange = abs(sfx->pSoundData[i]) >> 8;
++ sfx->fVolRange = abs(static_cast<int>(sfx->pSoundData[i])) >> 8;
+ }
+ }
+ #endif
+diff --git a/codemp/client/snd_mem.cpp b/codemp/client/snd_mem.cpp
+index 62adbdd1..ba07a335 100644
+--- a/codemp/client/snd_mem.cpp
++++ b/codemp/client/snd_mem.cpp
+@@ -839,9 +839,11 @@ static qboolean S_LoadSound_Actual( sfx_t *sfx )
+ for (int i = 0; i < sfx->iSoundLengthInSamples; i++)
+ {
+ sfx->pSoundData[i] = LittleShort(sfx->pSoundData[i]);
+- if (sfx->fVolRange < (abs(sfx->pSoundData[i]) >> 8))
++ // C++11 defines double abs(short) which is not what we want here,
++ // because double >> int is not defined. Force interpretation as int
++ if (sfx->fVolRange < (abs(static_cast<int>(sfx->pSoundData[i])) >> 8))
+ {
+- sfx->fVolRange = abs(sfx->pSoundData[i]) >> 8;
++ sfx->fVolRange = abs(static_cast<int>(sfx->pSoundData[i])) >> 8;
+ }
+ }
+ #endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git
More information about the Pkg-games-commits
mailing list