Date: Mon, 31 Aug 2015 10:14:21 +0200 From: Tijl Coosemans <tijl@FreeBSD.org> To: Alexey Dokuchaev <danfe@FreeBSD.org> Cc: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: Re: svn commit: r395648 - head/graphics/appleseed/files Message-ID: <20150831101421.4a9f0528@kalimero.tijl.coosemans.org> In-Reply-To: <201508310442.t7V4gxnm038292@repo.freebsd.org> References: <201508310442.t7V4gxnm038292@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 31 Aug 2015 04:42:59 +0000 (UTC) Alexey Dokuchaev <danfe@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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150831101421.4a9f0528>