wasm32.inc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2017 by the Free Pascal development team.
  4. Processor dependent implementation for the system unit for
  5. WebAssembly 32-bit
  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. procedure fpc_cpuinit;
  13. begin
  14. end;
  15. {$define FPC_SYSTEM_HAS_FILLCHAR}
  16. Procedure FillChar(var x;count:SizeInt;value:byte);
  17. begin
  18. if count>0 then
  19. fpc_wasm32_memory_fill(PtrUInt(@x),value,count);
  20. end;
  21. {$define FPC_SYSTEM_HAS_MOVE}
  22. procedure Move(const source;var dest;count:SizeInt);[public, alias: 'FPC_MOVE'];
  23. begin
  24. if count>0 then
  25. fpc_wasm32_memory_copy(PtrUInt(@dest),PtrUInt(@source),count);
  26. end;
  27. {$define FPC_SYSTEM_HAS_GET_PC_ADDR}
  28. Function Get_pc_addr : CodePointer;
  29. begin
  30. { dummy, produces a small, fake backtrace, otherwise programs terminate
  31. with no output at all, in case of a runtime error }
  32. result:=CodePointer($eeeeeeef);
  33. end;
  34. {$define FPC_SYSTEM_HAS_GET_CALLER_ADDR}
  35. function get_caller_addr(framebp:pointer;addr:codepointer=nil):pointer;
  36. begin
  37. { dummy, produces a small, fake backtrace, otherwise programs terminate
  38. with no output at all, in case of a runtime error }
  39. if addr=CodePointer($eeeeeeef) then
  40. result:=CodePointer($eeeeeeee)
  41. else
  42. result:=nil;
  43. end;
  44. {$define FPC_SYSTEM_HAS_GET_CALLER_FRAME}
  45. function get_caller_frame(framebp:pointer;addr:pointer=nil):pointer;
  46. begin
  47. result:=nil;
  48. end;
  49. {$define FPC_SYSTEM_HAS_SPTR}
  50. function Sptr : pointer;
  51. begin
  52. result:=nil;
  53. end;
  54. function InterLockedDecrement (var Target: longint) : longint;
  55. begin
  56. dec(Target);
  57. Result:=Target;
  58. end;
  59. function InterLockedIncrement (var Target: longint) : longint;
  60. begin
  61. inc(Target);
  62. Result:=Target;
  63. end;
  64. function InterLockedExchange (var Target: longint;Source : longint) : longint;
  65. begin
  66. Result:=Target;
  67. Target:=Source;
  68. end;
  69. function InterlockedCompareExchange(var Target: longint; NewValue: longint; Comperand: longint): longint;
  70. begin
  71. Result:=Target;
  72. if Target=Comperand then
  73. Target:=NewValue;
  74. end;
  75. function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint;
  76. begin
  77. Result:=Target;
  78. inc(Target,Source);
  79. end;
  80. function InterLockedDecrement (var Target: smallint) : smallint;
  81. begin
  82. dec(Target);
  83. Result:=Target;
  84. end;
  85. function InterLockedIncrement (var Target: smallint) : smallint;
  86. begin
  87. inc(Target);
  88. Result:=Target;
  89. end;
  90. function InterLockedExchange (var Target: smallint;Source : smallint) : smallint;
  91. begin
  92. Result:=Target;
  93. Target:=Source;
  94. end;
  95. function InterlockedCompareExchange(var Target: smallint; NewValue: smallint; Comperand: smallint): smallint;
  96. begin
  97. Result:=Target;
  98. if Target=Comperand then
  99. Target:=NewValue;
  100. end;
  101. function InterLockedExchangeAdd (var Target: smallint;Source : smallint) : smallint;
  102. begin
  103. Result:=Target;
  104. inc(Target,Source);
  105. end;