Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
30591ebc
Commit
30591ebc
authored
May 10, 2017
by
Teng Qin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move FileDesc to separated header file
parent
b493aa6c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
63 deletions
+69
-63
src/cc/CMakeLists.txt
src/cc/CMakeLists.txt
+3
-1
src/cc/common.cc
src/cc/common.cc
+0
-34
src/cc/common.h
src/cc/common.h
+0
-25
src/cc/file_desc.h
src/cc/file_desc.h
+63
-0
src/cc/frontends/b/codegen_llvm.cc
src/cc/frontends/b/codegen_llvm.cc
+1
-1
src/cc/syms.h
src/cc/syms.h
+1
-1
src/cc/table_desc.h
src/cc/table_desc.h
+1
-1
No files found.
src/cc/CMakeLists.txt
View file @
30591ebc
...
...
@@ -67,7 +67,9 @@ target_link_libraries(bcc-static b_frontend clang_frontend bcc-loader-static ${c
install
(
TARGETS bcc-shared LIBRARY COMPONENT libbcc
DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
)
install
(
FILES bpf_common.h bpf_module.h bcc_syms.h bcc_exception.h libbpf.h perf_reader.h BPF.h BPFTable.h shared_table.h table_desc.h table_storage.h COMPONENT libbcc
install
(
FILES bpf_common.h bpf_module.h bcc_syms.h bcc_exception.h file_desc.h
libbpf.h perf_reader.h BPF.h BPFTable.h shared_table.h
table_desc.h table_storage.h COMPONENT libbcc
DESTINATION include/bcc
)
install
(
DIRECTORY compat/linux/ COMPONENT libbcc
DESTINATION include/bcc/compat/linux
...
...
src/cc/common.cc
View file @
30591ebc
...
...
@@ -15,7 +15,6 @@
*/
#include <fstream>
#include <sstream>
#include <unistd.h>
#include "common.h"
...
...
@@ -49,37 +48,4 @@ std::vector<int> get_possible_cpus() {
return
read_cpu_range
(
"/sys/devices/system/cpu/possible"
);
}
FileDesc
::
FileDesc
(
int
fd
)
:
fd_
(
fd
)
{}
FileDesc
::
FileDesc
(
FileDesc
&&
that
)
:
fd_
(
-
1
)
{
*
this
=
std
::
move
(
that
);
}
FileDesc
::~
FileDesc
()
{
if
(
fd_
>=
0
)
::
close
(
fd_
);
}
FileDesc
&
FileDesc
::
operator
=
(
int
fd
)
{
if
(
fd_
>=
0
)
::
close
(
fd_
);
fd_
=
fd
;
return
*
this
;
}
FileDesc
&
FileDesc
::
operator
=
(
FileDesc
&&
that
)
{
if
(
fd_
>=
0
)
::
close
(
fd_
);
fd_
=
that
.
fd_
;
that
.
fd_
=
-
1
;
return
*
this
;
}
FileDesc
FileDesc
::
dup
()
const
{
int
dup_fd
=
::
dup
(
fd_
);
return
FileDesc
(
dup_fd
);
}
FileDesc
::
operator
int
()
{
return
fd_
;
}
FileDesc
::
operator
int
()
const
{
return
fd_
;
}
}
// namespace ebpf
src/cc/common.h
View file @
30591ebc
...
...
@@ -17,8 +17,6 @@
#pragma once
#include <memory>
#include <string>
#include <tuple>
#include <vector>
namespace
ebpf
{
...
...
@@ -33,27 +31,4 @@ std::vector<int> get_online_cpus();
std
::
vector
<
int
>
get_possible_cpus
();
/// FileDesc is a helper class for managing open file descriptors. Copy is
/// disallowed (call dup instead), and cleanup happens automatically.
class
FileDesc
{
public:
explicit
FileDesc
(
int
fd
=
-
1
);
FileDesc
(
FileDesc
&&
that
);
FileDesc
(
const
FileDesc
&
that
)
=
delete
;
~
FileDesc
();
FileDesc
&
operator
=
(
int
fd
);
FileDesc
&
operator
=
(
FileDesc
&&
that
);
FileDesc
&
operator
=
(
const
FileDesc
&
that
)
=
delete
;
operator
int
();
operator
int
()
const
;
FileDesc
dup
()
const
;
private:
int
fd_
;
};
}
// namespace ebpf
src/cc/file_desc.h
0 → 100644
View file @
30591ebc
/*
* Copyright (c) 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <unistd.h>
namespace
ebpf
{
/// FileDesc is a helper class for managing open file descriptors. Copy is
/// disallowed (call dup instead), and cleanup happens automatically.
class
FileDesc
{
public:
explicit
FileDesc
(
int
fd
=
-
1
)
:
fd_
(
fd
)
{}
FileDesc
(
FileDesc
&&
that
)
:
fd_
(
-
1
)
{
*
this
=
std
::
move
(
that
);
}
FileDesc
(
const
FileDesc
&
that
)
=
delete
;
~
FileDesc
()
{
if
(
fd_
>=
0
)
::
close
(
fd_
);
}
FileDesc
&
operator
=
(
int
fd
)
{
if
(
fd_
>=
0
)
::
close
(
fd_
);
fd_
=
fd
;
return
*
this
;
}
FileDesc
&
operator
=
(
FileDesc
&&
that
)
{
if
(
fd_
>=
0
)
::
close
(
fd_
);
fd_
=
that
.
fd_
;
that
.
fd_
=
-
1
;
return
*
this
;
}
FileDesc
&
operator
=
(
const
FileDesc
&
that
)
=
delete
;
FileDesc
dup
()
const
{
int
dup_fd
=
::
dup
(
fd_
);
return
FileDesc
(
dup_fd
);
}
operator
int
()
{
return
fd_
;
}
operator
int
()
const
{
return
fd_
;
}
private:
int
fd_
;
};
}
// namespace ebpf
src/cc/frontends/b/codegen_llvm.cc
View file @
30591ebc
...
...
@@ -33,8 +33,8 @@
#include <llvm/IR/Module.h>
#include "bcc_exception.h"
#include "common.h"
#include "codegen_llvm.h"
#include "file_desc.h"
#include "lexer.h"
#include "libbpf.h"
#include "linux/bpf.h"
...
...
src/cc/syms.h
View file @
30591ebc
...
...
@@ -23,7 +23,7 @@
#include <unordered_set>
#include <vector>
#include "
common
.h"
#include "
file_desc
.h"
class
ProcStat
{
std
::
string
procfs_
;
...
...
src/cc/table_desc.h
View file @
30591ebc
...
...
@@ -23,7 +23,7 @@
#include <string>
#include "bcc_exception.h"
#include "
common
.h"
#include "
file_desc
.h"
namespace
clang
{
class
ASTContext
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment