fix(libkernel): accept fractional nanosecond kevent periods

This commit is contained in:
MarcZX100 committed 2026-10-17 16:28:55 +00:00
1 parent 66702f1cff
commit d71a1c5775
2 files changed
+7 -3

No files matched your search

@@ -98,9 +98,6 @@ std::optional<std::uint64_t> TimerPeriodNanos(std::int64_t data, std::uint32_t f
unit = 1000ULL;
break;
case NOTE_NSECONDS:
if (data >= 1000000000LL && data % 1000000000LL != 0) {
NotImplemented_nid_no_patch("kevent: EVFILT_TIMER NOTE_NSECONDS period above one second with a fraction");
}
unit = 1;
break;
default:
+7
View File
@@ -67,6 +67,7 @@ static constexpr std::uint32_t NoteTrigger = 0x01000000;
static constexpr std::uint32_t NoteFfcopy = 0xc0000000;
static constexpr std::uint32_t NoteFfor = 0x80000000;
static constexpr std::uint32_t NoteUseconds = 0x0004;
static constexpr std::uint32_t NoteNseconds = 0x0008;
static constexpr std::uint32_t NoteDelete = 0x0001;
static constexpr std::uint32_t NoteWrite = 0x0002;
static constexpr std::uint32_t NoteExtend = 0x0004;
@@ -167,6 +168,12 @@ static void Timers() {
Require(Poll(kq, events, 4) == 0);
RequireFailure(Apply(kq, Change(2, EvfiltTimer, EvDelete)), GuestEnoent);
Require(Apply(kq, Change(5, EvfiltTimer, EvAdd | EvOneshot, NoteNseconds, 1500000001)) == 0);
const KernelTimespec twoSeconds{2, 0};
Require(kevent_nid_postfix(kq, nullptr, 0, events, 4, &twoSeconds) == 1);
Require(events[0].ident == 5 && events[0].data == 1);
Require(Poll(kq, events, 4) == 0);
RequireFailure(Apply(kq, Change(3, EvfiltTimer, EvAdd, 0, -1)), GuestEinval);
RequireFailure(Apply(kq, Change(3, EvfiltTimer, EvAdd, 0x10, 5)), GuestEinval);
RequireFailure(Apply(kq, Change(3, EvfiltTimer, EvAdd, NoteUseconds | 0x1, 5)), GuestEinval);