]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Host/posix/PipePosix.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Host / posix / PipePosix.h
1 //===-- PipePosix.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 liblldb_Host_posix_PipePosix_h_
11 #define liblldb_Host_posix_PipePosix_h_
12 #if defined(__cplusplus)
13
14 #include "lldb/Host/PipeBase.h"
15
16 namespace lldb_private {
17
18 //----------------------------------------------------------------------
19 /// @class PipePosix PipePosix.h "lldb/Host/posix/PipePosix.h"
20 /// A posix-based implementation of Pipe, a class that abtracts
21 ///        unix style pipes.
22 ///
23 /// A class that abstracts the LLDB core from host pipe functionality.
24 //----------------------------------------------------------------------
25 class PipePosix : public PipeBase {
26 public:
27   static int kInvalidDescriptor;
28
29   PipePosix();
30   PipePosix(int read_fd, int write_fd);
31   PipePosix(const PipePosix &) = delete;
32   PipePosix(PipePosix &&pipe_posix);
33   PipePosix &operator=(const PipePosix &) = delete;
34   PipePosix &operator=(PipePosix &&pipe_posix);
35
36   ~PipePosix() override;
37
38   Status CreateNew(bool child_process_inherit) override;
39   Status CreateNew(llvm::StringRef name, bool child_process_inherit) override;
40   Status CreateWithUniqueName(llvm::StringRef prefix,
41                               bool child_process_inherit,
42                               llvm::SmallVectorImpl<char> &name) override;
43   Status OpenAsReader(llvm::StringRef name,
44                       bool child_process_inherit) override;
45   Status
46   OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit,
47                           const std::chrono::microseconds &timeout) override;
48
49   bool CanRead() const override;
50   bool CanWrite() const override;
51
52   int GetReadFileDescriptor() const override;
53   int GetWriteFileDescriptor() const override;
54   int ReleaseReadFileDescriptor() override;
55   int ReleaseWriteFileDescriptor() override;
56   void CloseReadFileDescriptor() override;
57   void CloseWriteFileDescriptor() override;
58
59   // Close both descriptors
60   void Close() override;
61
62   Status Delete(llvm::StringRef name) override;
63
64   Status Write(const void *buf, size_t size, size_t &bytes_written) override;
65   Status ReadWithTimeout(void *buf, size_t size,
66                          const std::chrono::microseconds &timeout,
67                          size_t &bytes_read) override;
68
69 private:
70   int m_fds[2];
71 };
72
73 } // namespace lldb_private
74
75 #endif // #if defined(__cplusplus)
76 #endif // liblldb_Host_posix_PipePosix_h_