Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 183a71a35b32e617a8dc018897895a32fc3d32df
parent 11273daeafa6b799e637df3064eb97b5530ddfa6
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 28 Apr 2021 14:52:03 -0400

docs/runtime.txt: document additional functions

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Mdocs/runtime.txt | 34++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+), 0 deletions(-)

diff --git a/docs/runtime.txt b/docs/runtime.txt @@ -10,6 +10,40 @@ fn @noreturn rt::abort_fixed(reason: int) void 0: Slice or array access out-of-bounds 1: Type assertion failed +fn memcpy(dest: *void, src: *void, n: size) void; + Copy "n" bytes from "src" to "dest". The memory areas shall not + overlap. + +fn memmove(dest: *void, src: *void, n: size) void; + Copy "n" bytes from "src" to "dest". The memory areas may overlap. + +fn memset(dest: *void, val: u8, n: size) void; + Set "n" bytes, starting from the address at "dest", to "val". + +fn strcmp(a: str, b: str) bool; + Compare strings "a" and "b", returning true of they are equal. + +"ensure" and "unensure" are called when slices are expanded or deleted. The +"length" field of the slice will have been updated, and ensure should allocate +or re-allocate the data field to have sufficient space, and update the capacity +field accordingly. "unensure" is called when the space is no longer needed, and +should shrink the allocation as appropriate. + + type slice = struct { + data: *void, + length: size, + capacity: size, + }; + + fn ensure(s: *slice, membsz: size) void; + fn unensure(s: *slice, membsz: size) void; + +"malloc" and "free" are required to support the "alloc" and "free" built-ins. + + fn malloc(n: size) nullable *void; + + @symbol("rt.free") fn free_(_p: nullable *void) void; + The runtime is also expected to provide startup code. A list of function pointers of type `fn() void` is provided in the __init_array_start and __fini_array_start globals, which are respectively terminated by