File tree Expand file tree Collapse file tree 2 files changed +43
-17
lines changed Expand file tree Collapse file tree 2 files changed +43
-17
lines changed Original file line number Diff line number Diff line change @@ -32,23 +32,6 @@ THE SOFTWARE.
32
32
33
33
namespace unjit {
34
34
35
- struct FileDescriptor {
36
- private:
37
- int fd_;
38
- public:
39
- explicit FileDescriptor (int fd) : fd_(fd) {}
40
- ~FileDescriptor ()
41
- {
42
- close (fd_);
43
- }
44
- FileDescriptor (FileDescriptor&) = delete ;
45
- FileDescriptor& operator =(FileDescriptor&) = delete ;
46
- operator int () const
47
- {
48
- return fd_;
49
- }
50
- };
51
-
52
35
class elf_deleter {
53
36
public:
54
37
void operator ()(Elf* elf) const
Original file line number Diff line number Diff line change @@ -33,11 +33,54 @@ THE SOFTWARE.
33
33
#include < iostream>
34
34
#include < vector>
35
35
36
+ #include < unistd.h>
37
+
36
38
#include < llvm-c/Target.h>
37
39
#include < llvm-c/Disassembler.h>
38
40
39
41
namespace unjit {
40
42
43
+ struct FileDescriptor {
44
+ private:
45
+ int fd_;
46
+ public:
47
+ FileDescriptor () : fd_(-1 ) {}
48
+ explicit FileDescriptor (int fd) : fd_(fd) {}
49
+ ~FileDescriptor ()
50
+ {
51
+ this ->close ();
52
+ }
53
+
54
+ FileDescriptor (FileDescriptor&) = delete ;
55
+ FileDescriptor& operator =(FileDescriptor&) = delete ;
56
+
57
+ FileDescriptor (FileDescriptor&& that)
58
+ {
59
+ this ->close ();
60
+ this ->fd_ = that.fd_ ;
61
+ that.fd_ = -1 ;
62
+ }
63
+ FileDescriptor& operator =(FileDescriptor&& that)
64
+ {
65
+ this ->close ();
66
+ this ->fd_ = that.fd_ ;
67
+ that.fd_ = -1 ;
68
+ return *this ;
69
+ }
70
+
71
+ operator int () const
72
+ {
73
+ return fd_;
74
+ }
75
+ void close ()
76
+ {
77
+ if (fd_ >= 0 ) {
78
+ ::close (fd_);
79
+ fd_ = -1 ;
80
+ }
81
+ }
82
+ };
83
+
41
84
struct Symbol {
42
85
std::uint64_t value;
43
86
std::uint64_t size;
You can’t perform that action at this time.
0 commit comments