svn commit: r395648 - head/graphics/appleseed/files

Tijl Coosemans tijl at FreeBSD.org
Mon Aug 31 08:15:34 UTC 2015


On Mon, 31 Aug 2015 04:42:59 +0000 (UTC) Alexey Dokuchaev <danfe at FreeBSD.org> wrote:
> Author: danfe
> Date: Mon Aug 31 04:42:58 2015
> New Revision: 395648
> URL: https://svnweb.freebsd.org/changeset/ports/395648
> 
> Log:
>   - Use %edi register to save/restore contents of %ebx instead of pushing
>     it on stack to make the code work for both 32/64-bit x86
>   - Make the corresponding comment more accurate while I'm at it
>   
>   Reported by:	pkg-fallout
> 
> Modified:
>   head/graphics/appleseed/files/patch-src_appleseed_foundation_platform_system.cpp
> 
> Modified: head/graphics/appleseed/files/patch-src_appleseed_foundation_platform_system.cpp
> ==============================================================================
> --- head/graphics/appleseed/files/patch-src_appleseed_foundation_platform_system.cpp	Mon Aug 31 02:54:15 2015	(r395647)
> +++ head/graphics/appleseed/files/patch-src_appleseed_foundation_platform_system.cpp	Mon Aug 31 04:42:58 2015	(r395648)
> @@ -15,7 +15,7 @@
>   // Other platforms.
>   #else
>   
> -@@ -421,6 +429,384 @@ uint64 System::get_process_virtual_memor
> +@@ -421,6 +429,386 @@ uint64 System::get_process_virtual_memor
>       return static_cast<uint64>(rss) * sysconf(_SC_PAGESIZE);
>   }
>   
> @@ -43,16 +43,17 @@
>  +    size_t linesize;
>  +} mycaches[3];
>  +
> -+// %ebx may be used to store GOT (Global Offset Table) for PIC (Position
> -+// Independent Code), so use %esi instead.
> ++// %ebx is used to point to GOT (Global Offset Table) for PIC (Position
> ++// Independent Code) on 32-bit x86, so use %edi to preserve %ebx across
> ++// the call and %esi when passing CPUID arguments and return values.
>  +static inline void
>  +cpuid(uint32_t* data)
>  +{
> -+    asm("pushl %%ebx\n\t"
> ++    asm("movl %%ebx, %%edi\n\t"
>  +        "movl %%esi, %%ebx\n\t"
>  +        "cpuid\n\t"
>  +        "movl %%ebx, %%esi\n\t"
> -+        "popl %%ebx"
> ++        "movl %%edi, %%ebx"
>  +      : "=a" (data[eax]),
>  +        "=S" (data[ebx]),
>  +        "=c" (data[ecx]),
> @@ -60,7 +61,8 @@
>  +      :  "a" (data[eax]),
>  +         "S" (data[ebx]),
>  +         "c" (data[ecx]),
> -+         "d" (data[edx]));
> ++         "d" (data[edx])
> ++      : "%edi");
>  +}
>  +
>  +// For modern CPUs, we use Deterministic Cache Parameters (Function 04h) to

You can simply use:

asm("cpuid" : "+a" (data[eax]), "=b" (data[ebx]),
              "+c" (data[ecx]), "=d" (data[edx]));

The compiler will preserve any registers if necessary.  It might have
saved ebx somewhere already for some other reason.  Also, for cpuid eax
and ecx are intput/output and ebx and edx are output only.


More information about the svn-ports-all mailing list