2
0

cpu.pp 2.3 KB

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