FreeBSD Bugzilla – Attachment 221412 Details for
Bug 252539
[PATCH] kevent(2): wrong EVFILT_TIMER timeouts when using NOTE_NSECONDS
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
reproducer
main.c (text/plain), 1.42 KB, created by
Jan Kokemüller
on 2021-01-09 09:41:08 UTC
(
hide
)
Description:
reproducer
Filename:
MIME Type:
Creator:
Jan Kokemüller
Created:
2021-01-09 09:41:08 UTC
Size:
1.42 KB
patch
obsolete
>#include <sys/event.h> > >#include <err.h> >#include <stdio.h> >#include <time.h> > >#define REQUIRE(x) \ > do { \ > if (!(x)) { \ > errx(1, "error in line %d", __LINE__); \ > } \ > } while (0); > >int >main() >{ > int kq = kqueue(); > REQUIRE(kq >= 0); > >#define SLEEP_NSEC (1900010000) > > struct kevent kev; > EV_SET(&kev, 0, EVFILT_TIMER, EV_ADD | EV_ONESHOT, /**/ > NOTE_NSECONDS, SLEEP_NSEC, 0); > > REQUIRE(kevent(kq, &kev, 1, NULL, 0, NULL) == 0); > > struct timespec ts_begin; > REQUIRE(clock_gettime(CLOCK_MONOTONIC, &ts_begin) == 0); > > REQUIRE(kevent(kq, NULL, 0, &kev, 1, NULL) == 1); > > struct timespec ts_end; > REQUIRE(clock_gettime(CLOCK_MONOTONIC, &ts_end) == 0); > > struct timespec ts_duration = { > .tv_sec = ts_end.tv_sec - ts_begin.tv_sec, > .tv_nsec = ts_end.tv_nsec - ts_begin.tv_nsec, > }; > if (ts_duration.tv_nsec < 0) { > --ts_duration.tv_sec; > ts_duration.tv_nsec += 1000000000; > } > > fprintf(stderr, "sleep requested: %lld.%09lld\n", > (long long)SLEEP_NSEC / 1000000000, > (long long)SLEEP_NSEC % 1000000000); > fprintf(stderr, "actual duration: %lld.%09lld\n", > (long long)ts_duration.tv_sec, /**/ > (long long)ts_duration.tv_nsec); > > long long duration_ns = 1000000000 * ts_duration.tv_sec + > ts_duration.tv_nsec; > REQUIRE(duration_ns >= SLEEP_NSEC); >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 252539
: 221412 |
221413