system.pp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. unit system;
  2. interface
  3. type
  4. integer = longint;
  5. hresult = integer;
  6. ttypekind = integer;
  7. filerec = integer;
  8. textrec = integer;
  9. pbyte = ^byte;
  10. pchar = ^Char;
  11. procedure fpc_lib_exit; compilerproc;
  12. procedure DebugWrite(const P: PChar);
  13. implementation
  14. type
  15. P__wasi_size_t = ^__wasi_size_t;
  16. __wasi_size_t = longint;
  17. __wasi_fd_t = longint;
  18. size_t = longint;
  19. __wasi_errno_t = longint;
  20. P__wasi_ciovec_t = ^__wasi_ciovec_t;
  21. __wasi_ciovec_t = record
  22. buf: pointer;
  23. buf_len: __wasi_size_t;
  24. end;
  25. function fd_write(fd: __wasi_fd_t;
  26. iovs: P__wasi_ciovec_t;
  27. iovs_len: size_t;
  28. nwritten: P__wasi_size_t): __wasi_errno_t; external 'wasi_unstable';
  29. function StrLen(P: PChar): size_t;
  30. var
  31. lp: pchar;
  32. i: size_t;
  33. begin
  34. lp := p;
  35. i := 0;
  36. while lp[i]<>#0 do
  37. Inc(i);
  38. StrLen := i;
  39. end;
  40. procedure DebugWrite(const P: PChar);
  41. var
  42. our_iov: __wasi_ciovec_t;
  43. our_nwritten: longint;
  44. begin
  45. our_iov.buf := P;
  46. our_iov.buf_len := StrLen(P);
  47. fd_write(1, @our_iov, 1, @our_nwritten);
  48. end;
  49. procedure fpc_lib_exit; compilerproc;
  50. begin
  51. end;
  52. end.