cpu.pp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. {$ifdef symbian}
  15. {$define NO_ELF_SUPPORT}
  16. {$endif}
  17. interface
  18. function VFPv4Support : Boolean;
  19. implementation
  20. var
  21. has_vfpv4_support,
  22. gothwcaps : boolean;
  23. hwcaps : dword;
  24. const
  25. AT_NULL = 0;
  26. AT_HWCAPS = 16;
  27. type
  28. TAuxiliaryValue = DWord;
  29. TInternalUnion = record
  30. a_val: DWord; //* Integer value */
  31. {* We use to have pointer elements added here. We cannot do that,
  32. though, since it does not work when using 32-bit definitions
  33. on 64-bit platforms and vice versa. *}
  34. end;
  35. Elf32_auxv_t = record
  36. a_type: DWord; //* Entry type */
  37. a_un: TInternalUnion;
  38. end;
  39. TElf32AuxiliaryVector = Elf32_auxv_t;
  40. PElf32AuxiliaryVector = ^TElf32AuxiliaryVector;
  41. var
  42. psysinfo: LongWord = 0;
  43. procedure InitHWCaps;
  44. var
  45. ep: PPChar;
  46. auxv: PElf32AuxiliaryVector;
  47. begin
  48. psysinfo := 0;
  49. {$ifndef NO_ELF_SUPPORT}
  50. ep := envp;
  51. while ep^ <> nil do
  52. Inc(ep);
  53. Inc(ep);
  54. auxv := PElf32AuxiliaryVector(ep);
  55. while auxv^.a_type <> AT_NULL do
  56. begin
  57. if auxv^.a_type = AT_HWCAPS then
  58. begin
  59. hwcaps := auxv^.a_un.a_val;
  60. gothwcaps := true;
  61. Break;
  62. end;
  63. Inc(auxv);
  64. end;
  65. {$endif ndef NO_ELF_SUPPORT}
  66. end;
  67. function VFPv4Support : Boolean;
  68. begin
  69. Result:=has_vfpv4_support;
  70. end;
  71. begin
  72. gothwcaps:=false;
  73. InitHWCaps;
  74. has_vfpv4_support:=gothwcaps and ((hwcaps and (1 shl 16))<>0);
  75. end.