summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authorRodger Combs <rodger.combs@gmail.com>2015-07-27 17:53:21 -0500
committerRodger Combs <rodger.combs@gmail.com>2015-07-27 17:53:21 -0500
commitdc78d6a0ce5a95a112b96d3b029172bb64d83252 (patch)
tree1ff4073f158b819b2881970d97539e06b04d4120 /libass
parentd787615845d78d8f8e6d1a4ffc3dc3eecd8a92f6 (diff)
downloadlibass-dc78d6a0ce5a95a112b96d3b029172bb64d83252.tar.bz2
libass-dc78d6a0ce5a95a112b96d3b029172bb64d83252.tar.xz
Fix crash when the OS doesn't support AVX2
Diffstat (limited to 'libass')
-rw-r--r--libass/ass_utils.c3
-rw-r--r--libass/x86/cpuid.asm16
-rw-r--r--libass/x86/cpuid.h7
3 files changed, 23 insertions, 3 deletions
diff --git a/libass/ass_utils.c b/libass/ass_utils.c
index a6a063b..94edf80 100644
--- a/libass/ass_utils.c
+++ b/libass/ass_utils.c
@@ -48,6 +48,9 @@ int has_avx(void)
if(!(ecx & (1 << 27))) // not OSXSAVE
return 0;
uint32_t misc = ecx;
+ ass_get_xgetbv(0, &eax, &edx);
+ if((eax & 0x6) != 0x6)
+ return 0;
eax = 0;
ass_get_cpuid(&eax, &ebx, &ecx, &edx);
return (ecx & 0x6) == 0x6 ? (misc >> 28) & 0x1 : 0; // check high bits are relevant, then AVX support
diff --git a/libass/x86/cpuid.asm b/libass/x86/cpuid.asm
index 13b2a2d..9ecf835 100644
--- a/libass/x86/cpuid.asm
+++ b/libass/x86/cpuid.asm
@@ -46,3 +46,19 @@ cglobal get_cpuid, 4, 5, 0
mov [r4], edx
pop rbx
RET
+
+;-----------------------------------------------------------------------------
+; void get_xgetbv( uint32_t op, uint32_t *eax, uint32_t *edx )
+;-----------------------------------------------------------------------------
+
+INIT_XMM
+cglobal get_xgetbv, 3, 7, 0
+ push r2
+ push r1
+ mov ecx, r0d
+ xgetbv
+ pop r4
+ mov [r4], eax
+ pop r4
+ mov [r4], edx
+ RET
diff --git a/libass/x86/cpuid.h b/libass/x86/cpuid.h
index 34e4b19..4dc0e22 100644
--- a/libass/x86/cpuid.h
+++ b/libass/x86/cpuid.h
@@ -15,10 +15,11 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-
+
#ifndef INTEL_CPUID_H
#define INTEL_CPUID_H
-
+
void ass_get_cpuid( uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
-
+void ass_get_xgetbv( uint32_t op, uint32_t *eax, uint32_t *edx );
+
#endif