summarylogtreecommitdiffstats
path: root/01-add-pr-3287.patch
blob: 3aa079b97c7cc9dea12858072142acf2b729c1a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
From ea861fe86743c8402bbad77d8d1dd9de8dce447e Mon Sep 17 00:00:00 2001
From: Mikkel Krautz <mikkel@krautz.dk>
Date: Fri, 29 Dec 2017 14:47:25 +0100
Subject: [PATCH 1/3] AudioOutput: do not use non-existant template version of
 std::abs.

This change fixes AudioOutput to use the float overload of std::abs:

    float std::abs(float);

instead of a non-existant template version.

Fixes mumble-voip/mumble#3281

Needs-Backport: 1.2.x
---
 src/mumble/AudioOutput.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mumble/AudioOutput.cpp b/src/mumble/AudioOutput.cpp
index cbe0c0e2b..7a0a5e2ab 100644
--- a/src/mumble/AudioOutput.cpp
+++ b/src/mumble/AudioOutput.cpp
@@ -437,7 +437,7 @@ bool AudioOutput::mix(void *outbuff, unsigned int nsamp) {
 					top[2] = 0.0f;
 				}
 
-				if (std::abs<float>(front[0] * top[0] + front[1] * top[1] + front[2] * top[2]) > 0.01f) {
+				if (std::abs(front[0] * top[0] + front[1] * top[1] + front[2] * top[2]) > 0.01f) {
 					// Not perpendicular. Assume Y up and rotate 90 degrees.
 
 					float azimuth = 0.0f;

From a221fedfd3ebc4e722077f56e057c11260839e44 Mon Sep 17 00:00:00 2001
From: Mikkel Krautz <mikkel@krautz.dk>
Date: Sun, 31 Dec 2017 01:33:51 +0100
Subject: [PATCH 2/3] mumble_pch.hpp: explicitly include <cmath>.

Previously, we implicitly relied on <cmath> being included
by some other header.

Make it explicit.
---
 src/mumble/mumble_pch.hpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mumble/mumble_pch.hpp b/src/mumble/mumble_pch.hpp
index ba87eab3b..dac5ba629 100644
--- a/src/mumble/mumble_pch.hpp
+++ b/src/mumble/mumble_pch.hpp
@@ -82,6 +82,7 @@
 #include <boost/weak_ptr.hpp>
 
 #include <algorithm>
+#include <cmath>
 
 #ifdef Q_OS_WIN
 #include "../qos2_mingw.h"

From 6ca110a2226b0559fca85d22f287ec8a14eee1d1 Mon Sep 17 00:00:00 2001
From: Mikkel Krautz <mikkel@krautz.dk>
Date: Fri, 29 Dec 2017 15:05:03 +0100
Subject: [PATCH 3/3] src/tests: add TestStdAbs test.

This adds a 'just-in-case' test for correct runtime behavior of std::abs's
float overload.
---
 src/tests/TestStdAbs/TestStdAbs.cpp | 31 +++++++++++++++++++++++++++++++
 src/tests/TestStdAbs/TestStdAbs.pro |  9 +++++++++
 src/tests/tests.pro                 |  3 ++-
 3 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 src/tests/TestStdAbs/TestStdAbs.cpp
 create mode 100644 src/tests/TestStdAbs/TestStdAbs.pro

diff --git a/src/tests/TestStdAbs/TestStdAbs.cpp b/src/tests/TestStdAbs/TestStdAbs.cpp
new file mode 100644
index 000000000..ae06787a9
--- /dev/null
+++ b/src/tests/TestStdAbs/TestStdAbs.cpp
@@ -0,0 +1,31 @@
+// Copyright 2005-2017 The Mumble Developers. All rights reserved.
+// Use of this source code is governed by a BSD-style license
+// that can be found in the LICENSE file at the root of the
+// Mumble source tree or at <https://www.mumble.info/LICENSE>.
+
+#include <QtCore>
+#include <QtTest>
+
+#include <cmath>
+
+/// Test the std::abs works with floats.
+/// In fixing mumble-voip/mumble#3281, I
+/// stumbled upon http://eigen.tuxfamily.org/bz/show_bug.cgi?id=619.
+/// It seems that, on some platforms, std::abs
+/// might not call through to the correct libc
+/// function.
+/// Test that it works for us.
+class TestStdAbs : public QObject {
+		Q_OBJECT
+	private slots:
+		void floatWorks();
+};
+
+void TestStdAbs::floatWorks() {
+	const float in = -1.5;
+	float out = std::abs(in);
+	QVERIFY(out > 1.2 && out < 1.8);
+}
+
+QTEST_MAIN(TestStdAbs)
+#include "TestStdAbs.moc"
diff --git a/src/tests/TestStdAbs/TestStdAbs.pro b/src/tests/TestStdAbs/TestStdAbs.pro
new file mode 100644
index 000000000..6fbff2969
--- /dev/null
+++ b/src/tests/TestStdAbs/TestStdAbs.pro
@@ -0,0 +1,9 @@
+# Copyright 2005-2017 The Mumble Developers. All rights reserved.
+# Use of this source code is governed by a BSD-style license
+# that can be found in the LICENSE file at the root of the
+# Mumble source tree or at <https://www.mumble.info/LICENSE>.
+
+include(../test.pri)
+
+TARGET = TestStdAbs
+SOURCES = TestStdAbs.cpp
diff --git a/src/tests/tests.pro b/src/tests/tests.pro
index ee778fb1b..1b55d0ae7 100644
--- a/src/tests/tests.pro
+++ b/src/tests/tests.pro
@@ -18,4 +18,5 @@ SUBDIRS += \
   TestServerResolver \
   TestSelfSignedCertificate \
   TestSSLLocks \
-  TestFFDHE
+  TestFFDHE \
+  TestStdAbs