]> git.sesse.net Git - vlc/blobdiff - include/vlc_cpu.h
Remove useless alloca() work-around
[vlc] / include / vlc_cpu.h
index befe49e7205c78a09b4d1284bbb9f5cd4d1fab2b..5b108fc9107b451073b01911e8a001568ebe445c 100644 (file)
@@ -30,36 +30,122 @@ VLC_API unsigned vlc_CPU(void);
 
 # if defined (__i386__) || defined (__x86_64__)
 #  define HAVE_FPU 1
-#  define CPU_CAPABILITY_MMX     (1<<3)
-#  define CPU_CAPABILITY_3DNOW   (1<<4)
-#  define CPU_CAPABILITY_MMXEXT  (1<<5)
-#  define CPU_CAPABILITY_SSE     (1<<6)
-#  define CPU_CAPABILITY_SSE2    (1<<7)
-#  define CPU_CAPABILITY_SSE3    (1<<8)
-#  define CPU_CAPABILITY_SSSE3   (1<<9)
-#  define CPU_CAPABILITY_SSE4_1  (1<<10)
-#  define CPU_CAPABILITY_SSE4_2  (1<<11)
-#  define CPU_CAPABILITY_SSE4A   (1<<12)
+#  define VLC_CPU_MMX    8
+#  define VLC_CPU_3dNOW  16
+#  define VLC_CPU_MMXEXT 32
+#  define VLC_CPU_SSE    64
+#  define VLC_CPU_SSE2   128
+#  define VLC_CPU_SSE3   256
+#  define VLC_CPU_SSSE3  512
+#  define VLC_CPU_SSE4_1 1024
+#  define VLC_CPU_SSE4_2 2048
+#  define VLC_CPU_SSE4A  4096
+#  define VLC_CPU_AVX    8192
+#  define VLC_CPU_AVX2   16384
+#  define VLC_CPU_XOP    32768
+#  define VLC_CPU_FMA4   65536
 
 # if defined (__MMX__)
+#  define vlc_CPU_MMX() (1)
 #  define VLC_MMX
-# elif VLC_GCC_VERSION(4, 4)
-#  define VLC_MMX __attribute__ ((__target__ ("mmx")))
 # else
-#  define VLC_MMX VLC_MMX_is_not_implemented_on_this_compiler
+#  define vlc_CPU_MMX() ((vlc_CPU() & VLC_CPU_MMX) != 0)
+#  if VLC_GCC_VERSION(4, 4)
+#   define VLC_MMX __attribute__ ((__target__ ("mmx")))
+#  else
+#   define VLC_MMX VLC_MMX_is_not_implemented_on_this_compiler
+#  endif
 # endif
 
 # if defined (__SSE__)
+#  define vlc_CPU_MMXEXT() (1)
+#  define vlc_CPU_SSE() (1)
 #  define VLC_SSE
-# elif VLC_GCC_VERSION(4, 4)
-#  define VLC_SSE __attribute__ ((__target__ ("sse")))
 # else
-#  define VLC_SSE VLC_SSE_is_not_implemented_on_this_compiler
+#  define vlc_CPU_MMXEXT() ((vlc_CPU() & VLC_CPU_MMXEXT) != 0)
+#  define vlc_CPU_SSE() ((vlc_CPU() & VLC_CPU_SSE) != 0)
+#  if VLC_GCC_VERSION(4, 4)
+#   define VLC_SSE __attribute__ ((__target__ ("sse")))
+#  else
+#   define VLC_SSE VLC_SSE_is_not_implemented_on_this_compiler
+#  endif
+# endif
+
+# ifdef __SSE2__
+#  define vlc_CPU_SSE2() (1)
+# else
+#  define vlc_CPU_SSE2() ((vlc_CPU() & VLC_CPU_SSE2) != 0)
+# endif
+
+# ifdef __SSE3__
+#  define vlc_CPU_SSE3() (1)
+# else
+#  define vlc_CPU_SSE3() ((vlc_CPU() & VLC_CPU_SSE3) != 0)
+# endif
+
+# ifdef __SSSE3__
+#  define vlc_CPU_SSSE3() (1)
+# else
+#  define vlc_CPU_SSSE3() ((vlc_CPU() & VLC_CPU_SSSE3) != 0)
+# endif
+
+# ifdef __SSE4_1__
+#  define vlc_CPU_SSE4_1() (1)
+# else
+#  define vlc_CPU_SSE4_1() ((vlc_CPU() & VLC_CPU_SSE4_1) != 0)
+# endif
+
+# ifdef __SSE4_2__
+#  define vlc_CPU_SSE4_2() (1)
+# else
+#  define vlc_CPU_SSE4_2() ((vlc_CPU() & VLC_CPU_SSE4_2) != 0)
+# endif
+
+# ifdef __SSE4A__
+#  define vlc_CPU_SSE4A() (1)
+# else
+#  define vlc_CPU_SSE4A() ((vlc_CPU() & VLC_CPU_SSE4A) != 0)
+# endif
+
+# ifdef __AVX__
+#  define vlc_CPU_AVX() (1)
+# else
+#  define vlc_CPU_AVX() ((vlc_CPU() & VLC_CPU_AVX) != 0)
+# endif
+
+# ifdef __AVX2__
+#  define vlc_CPU_AVX2() (1)
+# else
+#  define vlc_CPU_AVX2() ((vlc_CPU() & VLC_CPU_AVX2) != 0)
+# endif
+
+# ifdef __3dNOW__
+#  define vlc_CPU_3dNOW() (1)
+# else
+#  define vlc_CPU_3dNOW() ((vlc_CPU() & VLC_CPU_3dNOW) != 0)
+# endif
+
+# ifdef __XOP__
+#  define vlc_CPU_XOP() (1)
+# else
+#  define vlc_CPU_XOP() ((vlc_CPU() & VLC_CPU_XOP) != 0)
+# endif
+
+# ifdef __FMA4__
+#  define vlc_CPU_FMA4() (1)
+# else
+#  define vlc_CPU_FMA4() ((vlc_CPU() & VLC_CPU_FMA4) != 0)
 # endif
 
 # elif defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
 #  define HAVE_FPU 1
-#  define CPU_CAPABILITY_ALTIVEC (1<<16)
+#  define VLC_CPU_ALTIVEC 2
+
+#  ifdef ALTIVEC
+#   define vlc_CPU_ALTIVEC() (1)
+#  else
+#   define vlc_CPU_ALTIVEC() ((vlc_CPU() & VLC_CPU_ALTIVEC) != 0)
+#  endif
 
 # elif defined (__arm__)
 #  if defined (__VFP_FP__) && !defined (__SOFTFP__)
@@ -67,7 +153,28 @@ VLC_API unsigned vlc_CPU(void);
 #  else
 #   define HAVE_FPU 0
 #  endif
-#  define CPU_CAPABILITY_NEON    (1<<24)
+#  define VLC_CPU_ARMv6    4
+#  define VLC_CPU_ARM_NEON 2
+
+#  if defined (__ARM_ARCH_7A__)
+#   define VLC_CPU_ARM_ARCH 7
+#  elif defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6T2__)
+#   define VLC_CPU_ARM_ARCH 6
+#  else
+#   define VLC_CPU_ARM_ARCH 4
+#  endif
+
+#  if (VLC_CPU_ARM_ARCH >= 6)
+#   define vlc_CPU_ARMv6() (1)
+#  else
+#   define vlc_CPU_ARMv6() ((vlc_CPU() & VLC_CPU_ARMv6) != 0)
+#  endif
+
+#  ifdef __ARM_NEON__
+#   define vlc_CPU_ARM_NEON() (1)
+#  else
+#   define vlc_CPU_ARM_NEON() ((vlc_CPU() & VLC_CPU_ARM_NEON) != 0)
+#  endif
 
 # elif defined (__sparc__)
 #  define HAVE_FPU 1