Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: linux dependant ASM code for CPU capability detection
  4. //
  5. // $Workfile: $
  6. // $NoKeywords: $
  7. //=============================================================================//
  8. #define cpuid(in,a,b,c,d) \
  9. asm("pushl %%ebx\n\t" "cpuid\n\t" "movl %%ebx,%%esi\n\t" "pop %%ebx": "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (in));
  10. bool CheckMMXTechnology(void)
  11. {
  12. unsigned long eax,ebx,edx,unused;
  13. cpuid(1,eax,ebx,unused,edx);
  14. return edx & 0x800000;
  15. }
  16. bool CheckSSETechnology(void)
  17. {
  18. unsigned long eax,ebx,edx,unused;
  19. cpuid(1,eax,ebx,unused,edx);
  20. return edx & 0x2000000L;
  21. }
  22. bool CheckSSE2Technology(void)
  23. {
  24. unsigned long eax,ebx,edx,unused;
  25. cpuid(1,eax,ebx,unused,edx);
  26. return edx & 0x04000000;
  27. }
  28. bool Check3DNowTechnology(void)
  29. {
  30. unsigned long eax, unused;
  31. cpuid(0x80000000,eax,unused,unused,unused);
  32. if ( eax > 0x80000000L )
  33. {
  34. cpuid(0x80000001,unused,unused,unused,eax);
  35. return ( eax & 1<<31 );
  36. }
  37. return false;
  38. }