summaryrefslogtreecommitdiff
path: root/tests/syscalls.c
diff options
context:
space:
mode:
authorDavid Moc <personal@cdatgoose.org>2026-03-08 15:02:30 +0100
committerDavid Moc <personal@cdatgoose.org>2026-03-08 15:02:30 +0100
commitad035ac5d942c6448a6a0464b995c2868a8378db (patch)
tree9c2c779d544a45b4234a6a3c311aa7b612ea975e /tests/syscalls.c
parent0385817bb1301a778bb33f8405a435293b9f8905 (diff)
Gosh.\nFixed bugs in offsetting. Added syscalls. Cleaned up the previous commenting (used to pass the project thu claude to add comments but LLMs are dumb). Removed the LLM made test runner cuz fuck AI.HEADmaster
Diffstat (limited to 'tests/syscalls.c')
-rw-r--r--tests/syscalls.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/syscalls.c b/tests/syscalls.c
new file mode 100644
index 0000000..285e539
--- /dev/null
+++ b/tests/syscalls.c
@@ -0,0 +1,30 @@
+int strlen(char *s) {
+ int n = 0;
+ while (s[n] != 0) { n = n + 1; }
+ return n;
+}
+
+int puts_fd(int fd, char *s) {
+ return syscall(1, fd, s, strlen(s));
+}
+
+int main() {
+ puts_fd(1, "Hello from JIT syscall!\n");
+
+ int pid = syscall(39);
+ int pid_ok = pid > 0;
+
+ char msg[32];
+ msg[0] = 'P'; msg[1] = 'I'; msg[2] = 'D'; msg[3] = ' ';
+ msg[4] = 'o'; msg[5] = 'k'; msg[6] = ':'; msg[7] = ' ';
+ msg[8] = '0' + pid_ok;
+ msg[9] = '\n';
+ syscall(1, 1, msg, 10);
+
+ int n1 = syscall(1, 1, "write test 1\n", 13);
+ int n2 = syscall(1, 1, "write test 2\n", 13);
+
+ int result = pid_ok + (n1 == 13) + (n2 == 13);
+
+ return result;
+}