libbsd: Use timespec_to_bigtime for time conversions in kqueue.

The FreeBSD manpage indicates that it will fail with EINVAL if
an invalid timespec is passed.
This commit is contained in:
Augustin Cavalier
2024-09-09 17:33:04 -04:00
parent 6a2d53e723
commit cf5249749d
2 changed files with 6 additions and 3 deletions
+1 -2
View File
@@ -11,9 +11,8 @@
#include <sys/time.h> #include <sys/time.h>
#include <time.h> #include <time.h>
#include <SupportDefs.h> #include <OS.h>
#include <new>
#define CLOCKS_PER_SEC_BEOS 1000 #define CLOCKS_PER_SEC_BEOS 1000
#define CLK_TCK_BEOS CLOCKS_PER_SEC_BEOS #define CLK_TCK_BEOS CLOCKS_PER_SEC_BEOS
+5 -1
View File
@@ -7,6 +7,7 @@
#include <StackOrHeapArray.h> #include <StackOrHeapArray.h>
#include <libroot/errno_private.h> #include <libroot/errno_private.h>
#include <libroot/time_private.h>
#include <syscalls.h> #include <syscalls.h>
#include <event_queue_defs.h> #include <event_queue_defs.h>
@@ -187,7 +188,10 @@ kevent(int kq,
bigtime_t timeout = 0; bigtime_t timeout = 0;
uint32 waitFlags = 0; uint32 waitFlags = 0;
if (tspec != NULL) { if (tspec != NULL) {
timeout = (tspec->tv_sec * 1000000LL) + (tspec->tv_nsec / 1000LL); if (!timespec_to_bigtime(*tspec, timeout)) {
__set_errno(EINVAL);
return -1;
}
waitFlags |= B_RELATIVE_TIMEOUT; waitFlags |= B_RELATIVE_TIMEOUT;
} }