duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit a284c17186eadfcb02ac1e445e08cc9e7c5b874d
parent f733a834851d1218e69a39a3c6349e87a9730dd6
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Fri,  9 Sep 2022 07:25:25 -0400

cc/lib: new unit, the C library

Diffstat:
Mfs/app/cos/tools/blkpack.c | 2--
Afs/cc/lib.fs | 6++++++
Mfs/tests/cc/all.fs | 1+
Afs/tests/cc/lib.fs | 8++++++++
4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/fs/app/cos/tools/blkpack.c b/fs/app/cos/tools/blkpack.c @@ -1,8 +1,6 @@ // This doesn't actually work, I'm just drafting how it would look. // TODO: string formatting // TODO: string scanning -// TODO: add NULL const -// TODO: add strlen() (alias to c@) // TODO: add \n in string literals // TODO: do multiple "return" paths work? // TODO: can we "return" early in a void function? diff --git a/fs/cc/lib.fs b/fs/cc/lib.fs @@ -0,0 +1,6 @@ +\ C library +\ Isn't needed by the compiler, so it can have C code. + +0 const NULL +: strlen c@ ; + diff --git a/fs/tests/cc/all.fs b/fs/tests/cc/all.fs @@ -3,3 +3,4 @@ f<< tests/cc/tree.fs f<< tests/cc/ast.fs f<< tests/cc/vm.fs f<< tests/cc/cc.fs +f<< tests/cc/lib.fs diff --git a/fs/tests/cc/lib.fs b/fs/tests/cc/lib.fs @@ -0,0 +1,8 @@ +?f<< tests/harness.fs +?f<< cc/cc.fs +?f<< cc/lib.fs +testbegin +\ Tests for the C library +:cfunc int foo () { return strlen("Hello World!"); } +foo 12 #eq +testend