mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 09:59:08 +02:00
+ added DebugWrite to the WASI system unit
git-svn-id: branches/wasm@47182 -
This commit is contained in:
parent
fbe9e975e5
commit
76c48eb705
@ -9,26 +9,55 @@ type
|
|||||||
filerec = integer;
|
filerec = integer;
|
||||||
textrec = integer;
|
textrec = integer;
|
||||||
pbyte = ^byte;
|
pbyte = ^byte;
|
||||||
|
pchar = ^Char;
|
||||||
|
|
||||||
procedure fpc_lib_exit; compilerproc;
|
procedure fpc_lib_exit; compilerproc;
|
||||||
|
procedure DebugWrite(const P: PChar);
|
||||||
function test_rtl_function(a, b: integer): integer;
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
type
|
||||||
|
P__wasi_size_t = ^__wasi_size_t;
|
||||||
|
__wasi_size_t = longint;
|
||||||
|
__wasi_fd_t = longint;
|
||||||
|
size_t = longint;
|
||||||
|
__wasi_errno_t = longint;
|
||||||
|
|
||||||
|
P__wasi_ciovec_t = ^__wasi_ciovec_t;
|
||||||
|
__wasi_ciovec_t = record
|
||||||
|
buf: pointer;
|
||||||
|
buf_len: __wasi_size_t;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
our_iov: __wasi_ciovec_t;
|
||||||
|
our_nwritten: longint;
|
||||||
|
i: size_t;
|
||||||
|
gp: pchar;
|
||||||
|
|
||||||
|
function fd_write(fd: __wasi_fd_t;
|
||||||
|
iovs: P__wasi_ciovec_t;
|
||||||
|
iovs_len: size_t;
|
||||||
|
nwritten: P__wasi_size_t): __wasi_errno_t; external 'wasi_unstable';
|
||||||
|
|
||||||
|
function StrLen(P: PChar): size_t;
|
||||||
|
begin
|
||||||
|
gp := p;
|
||||||
|
i := 0;
|
||||||
|
while gp[i]<>#0 do
|
||||||
|
Inc(i);
|
||||||
|
StrLen := i;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure DebugWrite(const P: PChar);
|
||||||
|
begin
|
||||||
|
our_iov.buf := P;
|
||||||
|
our_iov.buf_len := StrLen(P);
|
||||||
|
fd_write(1, @our_iov, 1, @our_nwritten);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure fpc_lib_exit; compilerproc;
|
procedure fpc_lib_exit; compilerproc;
|
||||||
begin
|
begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function test_rtl_function(a, b: integer): integer;
|
|
||||||
var
|
|
||||||
tempvar: integer;
|
|
||||||
tempvar2: integer;
|
|
||||||
pv: pbyte;
|
|
||||||
begin
|
|
||||||
tempvar := a - b;
|
|
||||||
test_rtl_function := a + b;
|
|
||||||
{ pv := @tempvar2;}
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user