diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-06-07 21:02:47 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-06-07 21:03:27 +0100 |
| commit | b8b41c38b3f82a355bf3fe77966338a6b3108e76 (patch) | |
| tree | 410c71e8f5c08a7927c89eede7f7560e286b00c5 /runtime/src/shed.c | |
| parent | d52bb965c5f9c2548dfef67cca1b089db26ad71c (diff) | |
Add basic C runtime
Diffstat (limited to 'runtime/src/shed.c')
| -rw-r--r-- | runtime/src/shed.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/runtime/src/shed.c b/runtime/src/shed.c new file mode 100644 index 00000000..60d66e64 --- /dev/null +++ b/runtime/src/shed.c @@ -0,0 +1,18 @@ +#include <stdbool.h> +#include <unistd.h> + +#include "./shed.h" + +ShedObject const shed_unit = 0; + +ShedObject shed__builtins__print(ShedEnv env, ShedString value) { + size_t total_bytes_written = 0; + while (total_bytes_written < value->length) { + ssize_t bytes_written = write(STDOUT_FILENO, &value->data[total_bytes_written], value->length - total_bytes_written); + if (bytes_written == -1) { + break; + } + total_bytes_written += bytes_written; + } + return shed_unit; +} |
