Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 diff -u /src/cpu_detect_x86.cpp /src/cpu_detect_x86.cpp
2 --- /src/cpu_detect_x86.cpp
3 +++ /src/cpu_detect_x86.cpp
4 @@ -44,9 +44,8 @@
7 #if defined(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS)
8 -
9 - #if defined(__GNUC__) && defined(__i386__)
10 - // gcc
11 + #if defined(__GNUC__) && defined(HAVE_CPUID_H)
12 + // gcc and clang
13 #include "cpuid.h"
14 #elif defined(_M_IX86)
15 // windows non-gcc
16 @@ -97,18 +96,7 @@
18 uint res = 0;
20 -#if defined(__GNUC__)
21 - // GCC version of cpuid. Requires GCC 4.3.0 or later for __cpuid intrinsic support.
22 - uint eax, ebx, ecx, edx; // unsigned int is the standard type. uint is defined by the compiler and not guaranteed to be portable.
23 -
24 - // Check if no cpuid support.
25 - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) return 0; // always disable extensions.
26 -
27 - if (edx & bit_MMX) res = res | SUPPORT_MMX;
28 - if (edx & bit_SSE) res = res | SUPPORT_SSE;
29 - if (edx & bit_SSE2) res = res | SUPPORT_SSE2;
30 -
31 -#else
32 +#if !defined(__GNUC__)
33 // Window / VS version of cpuid. Notice that Visual Studio 2005 or later required
34 // for __cpuid intrinsic support.
35 int reg[4] = {-1};
36 @@ -121,7 +109,19 @@
37 if ((unsigned int)reg[3] & bit_MMX) res = res | SUPPORT_MMX;
38 if ((unsigned int)reg[3] & bit_SSE) res = res | SUPPORT_SSE;
39 if ((unsigned int)reg[3] & bit_SSE2) res = res | SUPPORT_SSE2;
40 +#elif defined(HAVE_CPUID_H)
41 + // GCC version of cpuid. Requires GCC 4.3.0 or later for __cpuid intrinsic support.
42 + uint eax, ebx, ecx, edx; // unsigned int is the standard type. uint is defined by the compiler and not guaranteed to be portable.
43 +
44 + // Check if no cpuid support.
45 + if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) return 0; // always disable extensions.
47 + if (edx & bit_MMX) res = res | SUPPORT_MMX;
48 + if (edx & bit_SSE) res = res | SUPPORT_SSE;
49 + if (edx & bit_SSE2) res = res | SUPPORT_SSE2;
50 +#else
51 + // Compatible with GCC but no cpuid.h.
52 + return 0;
53 #endif
55 return res & ~_dwDisabledISA;
56 diff -u /src/STTypes.h /src/STTypes.h
57 --- /src/STTypes.h
58 +++ /src/STTypes.h
59 @@ -54,12 +54,17 @@
60 #define SOUNDTOUCH_ALIGN_POINTER_16(x) ( ( (ulongptr)(x) + 15 ) & ~(ulongptr)15 )
63 -#if (defined(__GNUC__) && !defined(ANDROID))
64 - // In GCC, include soundtouch_config.h made by config scritps.
65 - // Skip this in Android compilation that uses GCC but without configure scripts.
66 - #include "soundtouch_config.h"
67 -#endif
68 +#include "soundtouch_config.h"
70 +#ifdef WIN32
71 +#ifdef BUILDING_SOUNDTOUCH
72 +#define EXPORT __declspec(dllexport)
73 +#else
74 +#define EXPORT __declspec(dllimport)
75 +#endif
76 +#else
77 +#define EXPORT
78 +#endif
80 namespace soundtouch
81 {
82 @@ -164,7 +169,7 @@
83 };
85 // define ST_NO_EXCEPTION_HANDLING switch to disable throwing std exceptions:
86 -// #define ST_NO_EXCEPTION_HANDLING 1
87 +#define ST_NO_EXCEPTION_HANDLING 1
88 #ifdef ST_NO_EXCEPTION_HANDLING
89 // Exceptions disabled. Throw asserts instead if enabled.
90 #include <assert.h>
91 diff -u /src/SoundTouch.h /src/SoundTouch.h
92 --- /src/SoundTouch.h
93 +++ /src/SoundTouch.h
94 @@ -141,7 +141,7 @@
95 /// tempo/pitch/rate/samplerate settings.
96 #define SETTING_NOMINAL_OUTPUT_SEQUENCE 7
98 -class SoundTouch : public FIFOProcessor
99 +class EXPORT SoundTouch : public FIFOProcessor
100 {
101 private:
102 /// Rate transposer class instance
103 diff -u /src/FIRFilter.cpp /src/FIRFilter.cpp
104 --- /src/FIRFilter.cpp
105 +++ /src/FIRFilter.cpp
106 @@ -46,6 +46,11 @@
107 #include "FIRFilter.h"
108 #include "cpu_detect.h"
110 +#ifdef _MSC_VER
111 +#include <malloc.h>
112 +#define alloca _alloca
113 +#endif
114 +
115 using namespace soundtouch;
117 /*****************************************************************************
118 @@ -291,9 +296,11 @@
120 FIRFilter * FIRFilter::newInstance()
121 {
122 +#if defined(SOUNDTOUCH_ALLOW_MMX) || defined(SOUNDTOUCH_ALLOW_SSE)
123 uint uExtensions;
125 uExtensions = detectCPUextensions();
126 +#endif
128 // Check if MMX/SSE instruction set extensions supported by CPU
130 diff -u /src/TDStretch.cpp /src/TDStretch.cpp
131 --- /src/TDStretch.cpp
132 +++ /src/TDStretch.cpp
133 @@ -624,9 +624,11 @@
135 TDStretch * TDStretch::newInstance()
136 {
137 +#if defined(SOUNDTOUCH_ALLOW_MMX) || defined(SOUNDTOUCH_ALLOW_SSE)
138 uint uExtensions;
140 uExtensions = detectCPUextensions();
141 +#endif
143 // Check if MMX/SSE instruction set extensions supported by CPU
145 diff -u /src/SoundTouch.cpp /src/SoundTouch.cpp
146 --- /src/SoundTouch.cpp
147 +++ /src/SoundTouch.cpp
148 @@ -80,6 +80,11 @@
149 #include "RateTransposer.h"
150 #include "cpu_detect.h"
152 +#ifdef _MSC_VER
153 +#include <malloc.h>
154 +#define alloca _alloca
155 +#endif
156 +
157 using namespace soundtouch;
159 /// test if two floating point numbers are equal