pnggccrd.c
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:5k
- /* pnggccrd.c was removed from libpng-1.2.20. */
- /* This code snippet is for use by configure's compilation test. */
- #if (!defined _MSC_VER) &&
- defined(PNG_ASSEMBLER_CODE_SUPPORTED) &&
- defined(PNG_MMX_CODE_SUPPORTED)
- int PNGAPI png_dummy_mmx_support(void);
- static int _mmx_supported = 2; // 0: no MMX; 1: MMX supported; 2: not tested
- int PNGAPI
- png_dummy_mmx_support(void) __attribute__((noinline));
- int PNGAPI
- png_dummy_mmx_support(void)
- {
- int result;
- #if defined(PNG_MMX_CODE_SUPPORTED) // superfluous, but what the heck
- __asm__ __volatile__ (
- #if defined(__x86_64__)
- "pushq %%rbx nt" // rbx gets clobbered by CPUID instruction
- "pushq %%rcx nt" // so does rcx...
- "pushq %%rdx nt" // ...and rdx (but rcx & rdx safe on Linux)
- "pushfq nt" // save Eflag to stack
- "popq %%rax nt" // get Eflag from stack into rax
- "movq %%rax, %%rcx nt" // make another copy of Eflag in rcx
- "xorl $0x200000, %%eax nt" // toggle ID bit in Eflag (i.e., bit 21)
- "pushq %%rax nt" // save modified Eflag back to stack
- "popfq nt" // restore modified value to Eflag reg
- "pushfq nt" // save Eflag to stack
- "popq %%rax nt" // get Eflag from stack
- "pushq %%rcx nt" // save original Eflag to stack
- "popfq nt" // restore original Eflag
- #else
- "pushl %%ebx nt" // ebx gets clobbered by CPUID instruction
- "pushl %%ecx nt" // so does ecx...
- "pushl %%edx nt" // ...and edx (but ecx & edx safe on Linux)
- "pushfl nt" // save Eflag to stack
- "popl %%eax nt" // get Eflag from stack into eax
- "movl %%eax, %%ecx nt" // make another copy of Eflag in ecx
- "xorl $0x200000, %%eax nt" // toggle ID bit in Eflag (i.e., bit 21)
- "pushl %%eax nt" // save modified Eflag back to stack
- "popfl nt" // restore modified value to Eflag reg
- "pushfl nt" // save Eflag to stack
- "popl %%eax nt" // get Eflag from stack
- "pushl %%ecx nt" // save original Eflag to stack
- "popfl nt" // restore original Eflag
- #endif
- "xorl %%ecx, %%eax nt" // compare new Eflag with original Eflag
- "jz 0f nt" // if same, CPUID instr. is not supported
- "xorl %%eax, %%eax nt" // set eax to zero
- // ".byte 0x0f, 0xa2 nt" // CPUID instruction (two-byte opcode)
- "cpuid nt" // get the CPU identification info
- "cmpl $1, %%eax nt" // make sure eax return non-zero value
- "jl 0f nt" // if eax is zero, MMX is not supported
- "xorl %%eax, %%eax nt" // set eax to zero and...
- "incl %%eax nt" // ...increment eax to 1. This pair is
- // faster than the instruction "mov eax, 1"
- "cpuid nt" // get the CPU identification info again
- "andl $0x800000, %%edx nt" // mask out all bits but MMX bit (23)
- "cmpl $0, %%edx nt" // 0 = MMX not supported
- "jz 0f nt" // non-zero = yes, MMX IS supported
- "movl $1, %%eax nt" // set return value to 1
- "jmp 1f nt" // DONE: have MMX support
- "0: nt" // .NOT_SUPPORTED: target label for jump instructions
- "movl $0, %%eax nt" // set return value to 0
- "1: nt" // .RETURN: target label for jump instructions
- #if defined(__x86_64__)
- "popq %%rdx nt" // restore rdx
- "popq %%rcx nt" // restore rcx
- "popq %%rbx nt" // restore rbx
- #else
- "popl %%edx nt" // restore edx
- "popl %%ecx nt" // restore ecx
- "popl %%ebx nt" // restore ebx
- #endif
- // "ret nt" // DONE: no MMX support
- // (fall through to standard C "ret")
- : "=a" (result) // output list
- : // any variables used on input (none)
- // no clobber list
- // , "%ebx", "%ecx", "%edx" // GRR: we handle these manually
- // , "memory" // if write to a variable gcc thought was in a reg
- // , "cc" // "condition codes" (flag bits)
- );
- _mmx_supported = result;
- #else
- _mmx_supported = 0;
- #endif /* PNG_MMX_CODE_SUPPORTED */
- return _mmx_supported;
- }
- #endif