Pārlūkot izejas kodu

Copied asm-bits from newest LibCpuId.
Updated documentation.

Lasse Öörni 12 gadi atpakaļ
vecāks
revīzija
6079e8cf84
3 mainītis faili ar 38 papildinājumiem un 13 dzēšanām
  1. 2 2
      Docs/GettingStarted.dox
  2. 4 6
      Readme.txt
  3. 32 5
      ThirdParty/LibCpuId/libcpuid/asm-bits.c

+ 2 - 2
Docs/GettingStarted.dox

@@ -10,7 +10,7 @@ Although all required third-party libraries are included as source code, there a
 
 - For Windows, the June 2010 DirectX SDK needs to be installed and its include and library directories set as Visual Studio global directories (Tools -> Options -> Projects and Solutions -> VC++ Directories in VS2008.)
 
-- For Linux, the following development packages need to be installed: libx11-dev, libxrandr-dev, libasound2-dev. Also install the package libgl1-mesa-dev if your GPU driver does not include OpenGL headers & libs. Because Urho3D is built as 32-bit, 64-bit systems require installing also 32-bit versions of the development libraries.
+- For Linux, the following development packages need to be installed: libx11-dev, libxrandr-dev, libasound2-dev. Also install the package libgl1-mesa-dev if your GPU driver does not include OpenGL headers & libs.  Building as 32-bit on a 64-bit system requires installing also the 32-bit versions of the development libraries.
 
 - For Mac OS X, the Xcode developer tools package should include everything necessary.
 
@@ -40,7 +40,7 @@ cmake_gcc.sh on both Linux and Mac OS X.
 -# For Visual Studio, open Urho3D.sln and build the configuration(s) you like. On Windows, using other compilers than Visual Studio is not officially supported. MinGW may work (cmake -G "MinGW Makefiles"), but may lack required DirectX headers. They can be copied to a MinGW installation from the following package: http://www.libsdl.org/extras/win32/common/directx-devel.tar.gz.\n
 For Eclipse on Linux, import the Eclipse's project(s) generated by CMake into the workspace. The Eclipse's projects are generated in "Urho3D-Eclipse-build" sub-directory sibling to Urho3D project directory. See "Importing existing projects" in Eclipse Help for detail steps. Select "Build All" or "Build Project" in the menu. Note that Eclipse requires CDT plugin to build C/C++ project.\n
 For GCC, execute make (by default, cmake_gcc.sh specifies to make a RelWithDebInfo build).\n
-For Xcode on Mac OS X, open Urho3D.xcodeproj and select the i386 architecture before building (CMake should already select this when generating the Xcode project). Compiling Urho3D as 64-bit is not supported.
+For Xcode on Mac OS X, open Urho3D.xcodeproj and build.
 
 After the build is complete, the programs can be run from the Bin directory.
 

+ 4 - 6
Readme.txt

@@ -107,8 +107,8 @@ successfully:
 - For Linux, the following development packages need to be installed:
   libx11-dev, libxrandr-dev, libasound2-dev. Also install the package
   libgl1-mesa-dev if your GPU driver does not include OpenGL headers & libs.
-  Because Urho3D is built as 32-bit, 64-bit systems require installing also
-  32-bit versions of the development libraries.
+  Building as 32-bit on a 64-bit system requires installing also the 32-bit
+  versions of the development libraries.
 
 - For Mac OS X, the Xcode developer tools package should include everything
   necessary.
@@ -161,9 +161,7 @@ plugin to build C/C++ project.
 For GCC, execute make (by default, cmake_gcc.sh specifies to make a
 RelWithDebInfo build).
 
-For Xcode on Mac OS X, open Urho3D.xcodeproj and select the i386 architecture
-before building (CMake should already select this when generating the Xcode
-project). Compiling Urho3D as 64-bit is not supported.
+For Xcode on Mac OS X, open Urho3D.xcodeproj and build.
 
 After the build is complete, the programs can be run from the Bin directory.
 
@@ -333,4 +331,4 @@ V1.1    - Object and scene model refactoring.
         - Added OpenGL and cross-platform support.
         - Switched to kNet library for networking.
 
-V1.0    - Original release.
+V1.0    - Original release.

+ 32 - 5
ThirdParty/LibCpuId/libcpuid/asm-bits.c

@@ -80,15 +80,42 @@ int cpuid_exists_by_eflags(void)
  * are implemented in separate .asm files. Otherwise, use inline assembly
  */
 #ifdef INLINE_ASM_SUPPORTED
-// Modified by Lasse Oorni for Urho3D: fixed crash on Linux / recent GCC
 void exec_cpuid(uint32_t *regs)
 {
 #ifdef COMPILER_GCC
+#	ifdef PLATFORM_X64
 	__asm __volatile(
+		"	mov	%0,	%%rdi\n"
+
+		"	push	%%rbx\n"
+		"	push	%%rcx\n"
+		"	push	%%rdx\n"
+		
+		"	mov	(%%rdi),	%%eax\n"
+		"	mov	4(%%rdi),	%%ebx\n"
+		"	mov	8(%%rdi),	%%ecx\n"
+		"	mov	12(%%rdi),	%%edx\n"
+		
+		"	cpuid\n"
+		
+		"	movl	%%eax,	(%%rdi)\n"
+		"	movl	%%ebx,	4(%%rdi)\n"
+		"	movl	%%ecx,	8(%%rdi)\n"
+		"	movl	%%edx,	12(%%rdi)\n"
+		"	pop	%%rdx\n"
+		"	pop	%%rcx\n"
+		"	pop	%%rbx\n"
+		:
+		:"m"(regs)
+		:"memory", "eax", "rdi"
+	);
+#	else
+	__asm __volatile(
+		"	mov	%0,	%%edi\n"
+
 		"	push	%%ebx\n"
 		"	push	%%ecx\n"
 		"	push	%%edx\n"
-		"	push	%%edi\n"
 		
 		"	mov	(%%edi),	%%eax\n"
 		"	mov	4(%%edi),	%%ebx\n"
@@ -101,14 +128,14 @@ void exec_cpuid(uint32_t *regs)
 		"	mov	%%ebx,	4(%%edi)\n"
 		"	mov	%%ecx,	8(%%edi)\n"
 		"	mov	%%edx,	12(%%edi)\n"
-		"	pop	%%edi\n"
 		"	pop	%%edx\n"
 		"	pop	%%ecx\n"
 		"	pop	%%ebx\n"
 		:
-		:"D"(regs)
-		:"eax"
+		:"m"(regs)
+		:"memory", "eax", "edi"
 	);
+#	endif /* COMPILER_GCC */
 #else
 #  ifdef COMPILER_MICROSOFT
 	__asm {