Go to the documentation of this file.00001
00002
00003
00004
00005 #if (!defined _MSC_VER) && \
00006 defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \
00007 defined(PNG_MMX_CODE_SUPPORTED)
00008
00009 int PNGAPI png_dummy_mmx_support(void);
00010
00011 static int _mmx_supported = 2;
00012
00013 int PNGAPI
00014 png_dummy_mmx_support(void) __attribute__((noinline));
00015
00016 int PNGAPI
00017 png_dummy_mmx_support(void)
00018 {
00019 int result;
00020 #if defined(PNG_MMX_CODE_SUPPORTED) // superfluous, but what the heck
00021 __asm__ __volatile__ (
00022 #if defined(__x86_64__)
00023 "pushq %%rbx \n\t"
00024 "pushq %%rcx \n\t"
00025 "pushq %%rdx \n\t"
00026 "pushfq \n\t"
00027 "popq %%rax \n\t"
00028 "movq %%rax, %%rcx \n\t"
00029 "xorl $0x200000, %%eax \n\t"
00030 "pushq %%rax \n\t"
00031 "popfq \n\t"
00032 "pushfq \n\t"
00033 "popq %%rax \n\t"
00034 "pushq %%rcx \n\t"
00035 "popfq \n\t"
00036 #else
00037 "pushl %%ebx \n\t"
00038 "pushl %%ecx \n\t"
00039 "pushl %%edx \n\t"
00040 "pushfl \n\t"
00041 "popl %%eax \n\t"
00042 "movl %%eax, %%ecx \n\t"
00043 "xorl $0x200000, %%eax \n\t"
00044 "pushl %%eax \n\t"
00045 "popfl \n\t"
00046 "pushfl \n\t"
00047 "popl %%eax \n\t"
00048 "pushl %%ecx \n\t"
00049 "popfl \n\t"
00050 #endif
00051 "xorl %%ecx, %%eax \n\t"
00052 "jz 0f \n\t"
00053
00054 "xorl %%eax, %%eax \n\t"
00055
00056 "cpuid \n\t"
00057 "cmpl $1, %%eax \n\t"
00058 "jl 0f \n\t"
00059
00060 "xorl %%eax, %%eax \n\t"
00061 "incl %%eax \n\t"
00062
00063 "cpuid \n\t"
00064 "andl $0x800000, %%edx \n\t"
00065 "cmpl $0, %%edx \n\t"
00066 "jz 0f \n\t"
00067
00068 "movl $1, %%eax \n\t"
00069 "jmp 1f \n\t"
00070
00071 "0: \n\t"
00072 "movl $0, %%eax \n\t"
00073 "1: \n\t"
00074 #if defined(__x86_64__)
00075 "popq %%rdx \n\t"
00076 "popq %%rcx \n\t"
00077 "popq %%rbx \n\t"
00078 #else
00079 "popl %%edx \n\t"
00080 "popl %%ecx \n\t"
00081 "popl %%ebx \n\t"
00082 #endif
00083
00084
00085
00086
00087 : "=a" (result)
00088
00089 :
00090
00091
00092
00093
00094
00095 );
00096 _mmx_supported = result;
00097 #else
00098 _mmx_supported = 0;
00099 #endif
00100
00101 return _mmx_supported;
00102 }
00103 #endif