blob: 8a23256f760a685dfd00b788587b82e7b12ae292 [file] [log] [blame]
Greg Clayton3fb2c932013-02-16 22:46:58 +00001//===--------------------- KQueue.h -----------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef utility_KQueue_h_
11#define utility_KQueue_h_
12
13#if defined(__APPLE__)
14#define LLDB_USE_KQUEUES
15#endif
16
17#ifdef LLDB_USE_KQUEUES
18
19#include <sys/types.h>
20#include <sys/event.h>
21#include <sys/time.h>
22
23#include "lldb-defines.h"
24
25namespace lldb_private {
26
27class KQueue
28{
29public:
30 KQueue() :
31 m_fd(-1)
32 {
33 }
34
35 ~KQueue()
36 {
37 Close();
38 }
39
40 bool
41 IsValid () const
42 {
43 return m_fd >= 0;
44 }
45
46 int
47 GetFD (bool can_create);
48
49 int
50 Close ();
51
52 bool
53 AddFDEvent (int fd,
54 bool read,
55 bool write,
56 bool vnode);
57
58 int
59 WaitForEvents (struct kevent *events,
60 int num_events,
61 Error &error,
62 uint32_t timeout_usec = UINT32_MAX); // UINT32_MAX means infinite timeout
63
64protected:
65 int m_fd; // The kqueue fd
66};
67
68} // namespace lldb_private
69
70#endif // #ifdef LLDB_USE_KQUEUES
71
72#endif // #ifndef utility_KQueue_h_