diff options
Diffstat (limited to 'src/core/ngx_cpuinfo.c')
-rw-r--r-- | src/core/ngx_cpuinfo.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/core/ngx_cpuinfo.c b/src/core/ngx_cpuinfo.c index a939635f8..f905cbc13 100644 --- a/src/core/ngx_cpuinfo.c +++ b/src/core/ngx_cpuinfo.c @@ -14,6 +14,39 @@ static ngx_inline void ngx_cpuid(uint32_t i, uint32_t *buf); +#if ( __i386__ ) + +static ngx_inline void +ngx_cpuid(uint32_t i, uint32_t *buf) +{ + + /* + * we could not use %ebx as output parameter if gcc builds PIC, + * and we could not save %ebx on stack, because %esp is used, + * when the -fomit-frame-pointer optimization is specified. + */ + + __asm__ ( + + " mov %%ebx, %%esi; " + + " cpuid; " + " mov %%eax, %0; " + " mov %%ebx, %1; " + " mov %%edx, %2; " + " mov %%ecx, %3; " + + " mov %%esi, %%ebx; " + + : "=m" (buf[0]), "=m" (buf[1]), "=m" (buf[2]), "=m" (buf[3]) + : "a" (i) + : "ecx", "edx", "esi" ); +} + + +#else /* __amd64__ */ + + static ngx_inline void ngx_cpuid(uint32_t i, uint32_t *buf) { @@ -32,6 +65,9 @@ ngx_cpuid(uint32_t i, uint32_t *buf) } +#endif + + /* auto detect the L2 cache line size of modern and widespread CPUs */ void |