1 //===--------------------- 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/lldb-defines.h" 24 25 namespace lldb_private { 26 27 class KQueue 28 { 29 public: KQueue()30 KQueue() : 31 m_fd(-1) 32 { 33 } 34 ~KQueue()35 ~KQueue() 36 { 37 Close(); 38 } 39 40 bool IsValid()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 64 protected: 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_ 73