2
0

cpu.pp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2016 by the Free Pascal development team
  4. This unit contains some routines to get informations about the
  5. processor
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$mode objfpc}
  13. unit cpu;
  14. interface
  15. function VFPv4Support : Boolean;
  16. implementation
  17. var
  18. has_vfpv4_support,
  19. gothwcaps : boolean;
  20. hwcaps : dword;
  21. const
  22. AT_NULL = 0;
  23. AT_HWCAPS = 16;
  24. type
  25. TAuxiliaryValue = DWord;
  26. TInternalUnion = record
  27. a_val: DWord; //* Integer value */
  28. {* We use to have pointer elements added here. We cannot do that,
  29. though, since it does not work when using 32-bit definitions
  30. on 64-bit platforms and vice versa. *}
  31. end;
  32. Elf32_auxv_t = record
  33. a_type: DWord; //* Entry type */
  34. a_un: TInternalUnion;
  35. end;
  36. TElf32AuxiliaryVector = Elf32_auxv_t;
  37. PElf32AuxiliaryVector = ^TElf32AuxiliaryVector;
  38. var
  39. psysinfo: LongWord = 0;
  40. procedure InitHWCaps;
  41. var
  42. ep: PPChar;
  43. auxv: PElf32AuxiliaryVector;
  44. begin
  45. psysinfo := 0;
  46. ep := envp;
  47. while ep^ <> nil do
  48. Inc(ep);
  49. Inc(ep);
  50. auxv := PElf32AuxiliaryVector(ep);
  51. while auxv^.a_type <> AT_NULL do
  52. begin
  53. if auxv^.a_type = AT_HWCAPS then
  54. begin
  55. hwcaps := auxv^.a_un.a_val;
  56. gothwcaps := true;
  57. Break;
  58. end;
  59. Inc(auxv);
  60. end;
  61. end;
  62. function VFPv4Support : Boolean;
  63. begin
  64. Result:=has_vfpv4_support;
  65. end;
  66. begin
  67. gothwcaps:=false;
  68. InitHWCaps;
  69. has_vfpv4_support:=gothwcaps and ((hwcaps and (1 shl 16))<>0);
  70. end.