start working on the dns resolver

This commit is contained in:
2026-03-14 12:24:51 +01:00
parent 3f9df4a32f
commit 9f4c494e09
4 changed files with 110 additions and 10 deletions

View File

@@ -183,9 +183,18 @@ func mem.write32[x: ptr, d: i64] : void
x[2] = (d >> 16) & 0xff
x[3] = (d >> 24) & 0xff
func mem.write16[x: ptr, d: i64] : void
x[0] = d & 0xff
x[1] = (d >> 8) & 0xff
func mem.write16be[x: ptr, d: i64] : void
x[0] = (d >> 8) & 0xff
x[1] = d & 0xff
func mem.write64[x: ptr, d: i64] : void
_builtin_set64(x, d)
// see emit_prologue for the io.printf wrapper
func io._printf_impl[s: str, args: ptr] : void
while s[0]
if s[0] == '%'
@@ -205,6 +214,8 @@ func io._printf_impl[s: str, args: ptr] : void
args = args + 8
else if s[0] == '%'
io.print_char('%')
else if s[0] == 0
break
else
io.print_char(s[0])
s = s + 1
@@ -279,6 +290,12 @@ struct io.Buffer
data: ptr
size: i64
func io.Buffer.alloc[size: i64] : io.Buffer
let buffer: io.Buffer = new io.Buffer
buffer->size = size
buffer->data = mem.alloc(size)
return buffer
func io.read_binary_file[path: str] : io.Buffer
let fd: i64 = _builtin_syscall(SYS_openat, -100, path, 0, 0)
if fd < 0