Skip to content

Conversation

@salfel
Copy link
Contributor

@salfel salfel commented Dec 13, 2025

Needed those syscalls in one of my projects, so just added them as they were not present before.

Below is also a file to test the functionality of the syscall

package main

import "core:fmt"
import "core:os"
import "core:sys/linux"

main :: proc() {
	timer_fd, _ := linux.timerfd_create(.MONOTONIC, {.NONBLOCK})
	timer_spec := linux.ITimer_Spec {
		interval = {time_nsec = 500 * 1000 * 1000},
		value = {time_sec = 1},
	}
	linux.timerfd_settime(timer_fd, nil, &timer_spec, nil)
	pollfds := []linux.Poll_Fd{{fd = cast(linux.Fd)timer_fd, events = {.IN}}}

	for {
		if ret, err := linux.poll(pollfds, -1); err != nil || ret < 0 {
			if err == .EINTR {
				continue
			}

			fmt.eprintln("poll error:", err)
			break
		}
		if .IN in pollfds[0].revents {
			buf := [8]byte{}
			size, _ := os.read(cast(os.Handle)timer_fd, buf[:])

			fmt.println("received timer", transmute(u64)buf)
		}
	}
}

@laytan laytan merged commit 7640a05 into odin-lang:master Dec 20, 2025
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants