1 //===--------------------- KQueue.cpp ---------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 #ifdef LLDB_USE_KQUEUES
14 #include "lldb/Core/Error.h"
16 #include "Utility/TimeSpecTimeout.h"
18 using namespace lldb_private;
21 KQueue::GetFD (bool can_create)
23 if (!IsValid () && can_create)
41 KQueue::WaitForEvents (struct kevent *events, int num_events, Error &error, uint32_t timeout_usec)
43 const int fd_kqueue = GetFD(false);
46 TimeSpecTimeout timeout;
47 const struct timespec *timeout_ptr = timeout.SetRelativeTimeoutMircoSeconds32 (timeout_usec);
48 int result = ::kevent(fd_kqueue, NULL, 0, events, num_events, timeout_ptr);
50 error.SetErrorToErrno();
57 error.SetErrorString("invalid kqueue fd");
63 KQueue::AddFDEvent (int fd, bool read, bool write, bool vnode)
65 const int fd_kqueue = GetFD(true);
72 event.filter |= EVFILT_READ;
74 event.filter |= EVFILT_WRITE;
76 event.filter |= EVFILT_VNODE;
77 event.flags = EV_ADD | EV_CLEAR;
81 int err = ::kevent(fd_kqueue, &event, 1, NULL, 0, NULL);