3dphotoshoot
diff libs/libpng/pnggccrd.c @ 14:06dc8b9b4f89
added libimago, libjpeg and libpng
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 07 Jun 2015 17:25:49 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/libpng/pnggccrd.c Sun Jun 07 17:25:49 2015 +0300 1.3 @@ -0,0 +1,103 @@ 1.4 +/* pnggccrd.c was removed from libpng-1.2.20. */ 1.5 + 1.6 +/* This code snippet is for use by configure's compilation test. */ 1.7 + 1.8 +#if (!defined _MSC_VER) && \ 1.9 + defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \ 1.10 + defined(PNG_MMX_CODE_SUPPORTED) 1.11 + 1.12 +int PNGAPI png_dummy_mmx_support(void); 1.13 + 1.14 +static int _mmx_supported = 2; // 0: no MMX; 1: MMX supported; 2: not tested 1.15 + 1.16 +int PNGAPI 1.17 +png_dummy_mmx_support(void) __attribute__((noinline)); 1.18 + 1.19 +int PNGAPI 1.20 +png_dummy_mmx_support(void) 1.21 +{ 1.22 + int result; 1.23 +#if defined(PNG_MMX_CODE_SUPPORTED) // superfluous, but what the heck 1.24 + __asm__ __volatile__ ( 1.25 +#if defined(__x86_64__) 1.26 + "pushq %%rbx \n\t" // rbx gets clobbered by CPUID instruction 1.27 + "pushq %%rcx \n\t" // so does rcx... 1.28 + "pushq %%rdx \n\t" // ...and rdx (but rcx & rdx safe on Linux) 1.29 + "pushfq \n\t" // save Eflag to stack 1.30 + "popq %%rax \n\t" // get Eflag from stack into rax 1.31 + "movq %%rax, %%rcx \n\t" // make another copy of Eflag in rcx 1.32 + "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) 1.33 + "pushq %%rax \n\t" // save modified Eflag back to stack 1.34 + "popfq \n\t" // restore modified value to Eflag reg 1.35 + "pushfq \n\t" // save Eflag to stack 1.36 + "popq %%rax \n\t" // get Eflag from stack 1.37 + "pushq %%rcx \n\t" // save original Eflag to stack 1.38 + "popfq \n\t" // restore original Eflag 1.39 +#else 1.40 + "pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction 1.41 + "pushl %%ecx \n\t" // so does ecx... 1.42 + "pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux) 1.43 + "pushfl \n\t" // save Eflag to stack 1.44 + "popl %%eax \n\t" // get Eflag from stack into eax 1.45 + "movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx 1.46 + "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) 1.47 + "pushl %%eax \n\t" // save modified Eflag back to stack 1.48 + "popfl \n\t" // restore modified value to Eflag reg 1.49 + "pushfl \n\t" // save Eflag to stack 1.50 + "popl %%eax \n\t" // get Eflag from stack 1.51 + "pushl %%ecx \n\t" // save original Eflag to stack 1.52 + "popfl \n\t" // restore original Eflag 1.53 +#endif 1.54 + "xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag 1.55 + "jz 0f \n\t" // if same, CPUID instr. is not supported 1.56 + 1.57 + "xorl %%eax, %%eax \n\t" // set eax to zero 1.58 +// ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode) 1.59 + "cpuid \n\t" // get the CPU identification info 1.60 + "cmpl $1, %%eax \n\t" // make sure eax return non-zero value 1.61 + "jl 0f \n\t" // if eax is zero, MMX is not supported 1.62 + 1.63 + "xorl %%eax, %%eax \n\t" // set eax to zero and... 1.64 + "incl %%eax \n\t" // ...increment eax to 1. This pair is 1.65 + // faster than the instruction "mov eax, 1" 1.66 + "cpuid \n\t" // get the CPU identification info again 1.67 + "andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23) 1.68 + "cmpl $0, %%edx \n\t" // 0 = MMX not supported 1.69 + "jz 0f \n\t" // non-zero = yes, MMX IS supported 1.70 + 1.71 + "movl $1, %%eax \n\t" // set return value to 1 1.72 + "jmp 1f \n\t" // DONE: have MMX support 1.73 + 1.74 + "0: \n\t" // .NOT_SUPPORTED: target label for jump instructions 1.75 + "movl $0, %%eax \n\t" // set return value to 0 1.76 + "1: \n\t" // .RETURN: target label for jump instructions 1.77 +#if defined(__x86_64__) 1.78 + "popq %%rdx \n\t" // restore rdx 1.79 + "popq %%rcx \n\t" // restore rcx 1.80 + "popq %%rbx \n\t" // restore rbx 1.81 +#else 1.82 + "popl %%edx \n\t" // restore edx 1.83 + "popl %%ecx \n\t" // restore ecx 1.84 + "popl %%ebx \n\t" // restore ebx 1.85 +#endif 1.86 + 1.87 +// "ret \n\t" // DONE: no MMX support 1.88 + // (fall through to standard C "ret") 1.89 + 1.90 + : "=a" (result) // output list 1.91 + 1.92 + : // any variables used on input (none) 1.93 + 1.94 + // no clobber list 1.95 +// , "%ebx", "%ecx", "%edx" // GRR: we handle these manually 1.96 +// , "memory" // if write to a variable gcc thought was in a reg 1.97 +// , "cc" // "condition codes" (flag bits) 1.98 + ); 1.99 + _mmx_supported = result; 1.100 +#else 1.101 + _mmx_supported = 0; 1.102 +#endif /* PNG_MMX_CODE_SUPPORTED */ 1.103 + 1.104 + return _mmx_supported; 1.105 +} 1.106 +#endif