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
3df1288d
Commit
3df1288d
authored
Sep 03, 2015
by
4ast
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #178 from iovisor/llvm_fixes
Fixes for when using clang/llvm as CC/CXX
parents
9226552c
fdc027cf
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
46 additions
and
47 deletions
+46
-47
src/cc/bpf_module.h
src/cc/bpf_module.h
+1
-1
src/cc/frontends/b/CMakeLists.txt
src/cc/frontends/b/CMakeLists.txt
+3
-0
src/cc/frontends/b/codegen_llvm.h
src/cc/frontends/b/codegen_llvm.h
+2
-2
src/cc/frontends/b/loader.cc
src/cc/frontends/b/loader.cc
+1
-1
src/cc/frontends/b/loader.h
src/cc/frontends/b/loader.h
+1
-1
src/cc/frontends/b/node.h
src/cc/frontends/b/node.h
+0
-3
src/cc/frontends/b/type_check.h
src/cc/frontends/b/type_check.h
+2
-3
src/cc/frontends/clang/loader.h
src/cc/frontends/clang/loader.h
+1
-1
src/cc/libbpf.c
src/cc/libbpf.c
+35
-35
No files found.
src/cc/bpf_module.h
View file @
3df1288d
...
...
@@ -31,7 +31,7 @@ class Type;
}
namespace
ebpf
{
class
TableDesc
;
struct
TableDesc
;
class
BLoader
;
class
ClangLoader
;
...
...
src/cc/frontends/b/CMakeLists.txt
View file @
3df1288d
...
...
@@ -7,6 +7,9 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
BISON_TARGET
(
Parser parser.yy
${
CMAKE_CURRENT_BINARY_DIR
}
/parser.yy.cc COMPILE_FLAGS
"-o parser.yy.cc -v --debug"
)
FLEX_TARGET
(
Lexer lexer.ll
${
CMAKE_CURRENT_BINARY_DIR
}
/lexer.ll.cc COMPILE_FLAGS
"--c++ --o lexer.ll.cc"
)
ADD_FLEX_BISON_DEPENDENCY
(
Lexer Parser
)
if
(
CMAKE_C_COMPILER_ID STREQUAL
"Clang"
)
set_source_files_properties
(
${
CMAKE_CURRENT_BINARY_DIR
}
/lexer.ll.cc PROPERTIES COMPILE_FLAGS
"-Wno-deprecated-register"
)
endif
()
add_library
(
b_frontend loader.cc codegen_llvm.cc node.cc parser.cc printer.cc
type_check.cc
${
BISON_Parser_OUTPUTS
}
${
FLEX_Lexer_OUTPUTS
}
)
src/cc/frontends/b/codegen_llvm.h
View file @
3df1288d
...
...
@@ -41,7 +41,7 @@ class GlobalVariable;
}
namespace
ebpf
{
class
TableDesc
;
struct
TableDesc
;
namespace
cc
{
...
...
@@ -63,7 +63,7 @@ class CodegenLLVM : public Visitor {
EXPAND_NODES
(
VISIT
)
#undef VISIT
virtual
STATUS_RETURN
visit
(
Node
*
n
,
std
::
vector
<
TableDesc
>
&
tables
);
STATUS_RETURN
visit
(
Node
*
n
,
std
::
vector
<
TableDesc
>
&
tables
);
int
get_table_fd
(
const
std
::
string
&
name
)
const
;
...
...
src/cc/frontends/b/loader.cc
View file @
3df1288d
...
...
@@ -54,7 +54,7 @@ int BLoader::parse(llvm::Module *mod, const string &filename, const string &prot
//ebpf::cc::Printer printer(stderr);
//printer.visit(parser_->root_node_);
ebpf
::
cc
::
TypeCheck
type_check
(
parser_
->
scopes_
.
get
(),
proto_parser_
->
scopes_
.
get
()
,
parser_
->
pragmas_
);
ebpf
::
cc
::
TypeCheck
type_check
(
parser_
->
scopes_
.
get
(),
proto_parser_
->
scopes_
.
get
());
auto
ret
=
type_check
.
visit
(
parser_
->
root_node_
);
if
(
get
<
0
>
(
ret
)
!=
0
||
get
<
1
>
(
ret
).
size
())
{
fprintf
(
stderr
,
"Type error @line=%d: %s
\n
"
,
get
<
0
>
(
ret
),
get
<
1
>
(
ret
).
c_str
());
...
...
src/cc/frontends/b/loader.h
View file @
3df1288d
...
...
@@ -26,7 +26,7 @@ class Module;
namespace
ebpf
{
class
TableDesc
;
struct
TableDesc
;
namespace
cc
{
class
Parser
;
...
...
src/cc/frontends/b/node.h
View file @
3df1288d
...
...
@@ -619,9 +619,6 @@ class Visitor {
public:
typedef
StatusTuple
Ret
;
virtual
~
Visitor
()
{}
virtual
STATUS_RETURN
visit
(
Node
*
n
)
{
return
n
->
accept
(
this
);
}
#define VISIT(type, func) virtual STATUS_RETURN visit_##func(type* n) = 0;
EXPAND_NODES
(
VISIT
)
#undef VISIT
...
...
src/cc/frontends/b/type_check.h
View file @
3df1288d
...
...
@@ -26,8 +26,8 @@ namespace cc {
class
TypeCheck
:
public
Visitor
{
public:
TypeCheck
(
Scopes
*
scopes
,
Scopes
*
proto_scopes
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
pragmas
)
:
scopes_
(
scopes
),
proto_scopes_
(
proto_scopes
)
,
pragmas_
(
pragmas
)
{}
TypeCheck
(
Scopes
*
scopes
,
Scopes
*
proto_scopes
)
:
scopes_
(
scopes
),
proto_scopes_
(
proto_scopes
)
{}
virtual
STATUS_RETURN
visit
(
Node
*
n
);
STATUS_RETURN
expect_method_arg
(
MethodCallExprNode
*
n
,
size_t
num
,
size_t
num_def_args
);
...
...
@@ -43,7 +43,6 @@ class TypeCheck : public Visitor {
Scopes
*
scopes_
;
Scopes
*
proto_scopes_
;
vector
<
string
>
errors_
;
const
std
::
map
<
std
::
string
,
std
::
string
>
&
pragmas_
;
};
}
// namespace cc
...
...
src/cc/frontends/clang/loader.h
View file @
3df1288d
...
...
@@ -27,7 +27,7 @@ class LLVMContext;
namespace
ebpf
{
class
TableDesc
;
struct
TableDesc
;
namespace
cc
{
class
Parser
;
...
...
src/cc/libbpf.c
View file @
3df1288d
...
...
@@ -59,56 +59,56 @@ static __u64 ptr_to_u64(void *ptr)
int
bpf_create_map
(
enum
bpf_map_type
map_type
,
int
key_size
,
int
value_size
,
int
max_entries
)
{
union
bpf_attr
attr
=
{
.
map_type
=
map_type
,
.
key_size
=
key_size
,
.
value_size
=
value_size
,
.
max_entries
=
max_entries
}
;
union
bpf_attr
attr
;
memset
(
&
attr
,
0
,
sizeof
(
attr
));
attr
.
map_type
=
map_type
;
attr
.
key_size
=
key_size
;
attr
.
value_size
=
value_size
;
attr
.
max_entries
=
max_entries
;
return
syscall
(
__NR_bpf
,
BPF_MAP_CREATE
,
&
attr
,
sizeof
(
attr
));
}
int
bpf_update_elem
(
int
fd
,
void
*
key
,
void
*
value
,
unsigned
long
long
flags
)
{
union
bpf_attr
attr
=
{
.
map_fd
=
fd
,
.
key
=
ptr_to_u64
(
key
),
.
value
=
ptr_to_u64
(
value
),
.
flags
=
flags
,
}
;
union
bpf_attr
attr
;
memset
(
&
attr
,
0
,
sizeof
(
attr
));
attr
.
map_fd
=
fd
;
attr
.
key
=
ptr_to_u64
(
key
);
attr
.
value
=
ptr_to_u64
(
value
);
attr
.
flags
=
flags
;
return
syscall
(
__NR_bpf
,
BPF_MAP_UPDATE_ELEM
,
&
attr
,
sizeof
(
attr
));
}
int
bpf_lookup_elem
(
int
fd
,
void
*
key
,
void
*
value
)
{
union
bpf_attr
attr
=
{
.
map_fd
=
fd
,
.
key
=
ptr_to_u64
(
key
),
.
value
=
ptr_to_u64
(
value
),
}
;
union
bpf_attr
attr
;
memset
(
&
attr
,
0
,
sizeof
(
attr
));
attr
.
map_fd
=
fd
;
attr
.
key
=
ptr_to_u64
(
key
);
attr
.
value
=
ptr_to_u64
(
value
)
;
return
syscall
(
__NR_bpf
,
BPF_MAP_LOOKUP_ELEM
,
&
attr
,
sizeof
(
attr
));
}
int
bpf_delete_elem
(
int
fd
,
void
*
key
)
{
union
bpf_attr
attr
=
{
.
map_fd
=
fd
,
.
key
=
ptr_to_u64
(
key
),
}
;
union
bpf_attr
attr
;
memset
(
&
attr
,
0
,
sizeof
(
attr
));
attr
.
map_fd
=
fd
;
attr
.
key
=
ptr_to_u64
(
key
)
;
return
syscall
(
__NR_bpf
,
BPF_MAP_DELETE_ELEM
,
&
attr
,
sizeof
(
attr
));
}
int
bpf_get_next_key
(
int
fd
,
void
*
key
,
void
*
next_key
)
{
union
bpf_attr
attr
=
{
.
map_fd
=
fd
,
.
key
=
ptr_to_u64
(
key
),
.
next_key
=
ptr_to_u64
(
next_key
),
}
;
union
bpf_attr
attr
;
memset
(
&
attr
,
0
,
sizeof
(
attr
));
attr
.
map_fd
=
fd
;
attr
.
key
=
ptr_to_u64
(
key
);
attr
.
next_key
=
ptr_to_u64
(
next_key
)
;
return
syscall
(
__NR_bpf
,
BPF_MAP_GET_NEXT_KEY
,
&
attr
,
sizeof
(
attr
));
}
...
...
@@ -122,15 +122,15 @@ int bpf_prog_load(enum bpf_prog_type prog_type,
const
char
*
license
,
unsigned
kern_version
,
char
*
log_buf
,
unsigned
log_buf_size
)
{
union
bpf_attr
attr
=
{
.
prog_type
=
prog_type
,
.
insns
=
ptr_to_u64
((
void
*
)
insns
),
.
insn_cnt
=
prog_len
/
sizeof
(
struct
bpf_insn
),
.
license
=
ptr_to_u64
((
void
*
)
license
),
.
log_buf
=
ptr_to_u64
(
log_buf
),
.
log_size
=
log_buf_size
,
.
log_level
=
log_buf
?
1
:
0
,
}
;
union
bpf_attr
attr
;
memset
(
&
attr
,
0
,
sizeof
(
attr
));
attr
.
prog_type
=
prog_type
;
attr
.
insns
=
ptr_to_u64
((
void
*
)
insns
);
attr
.
insn_cnt
=
prog_len
/
sizeof
(
struct
bpf_insn
);
attr
.
license
=
ptr_to_u64
((
void
*
)
license
);
attr
.
log_buf
=
ptr_to_u64
(
log_buf
);
attr
.
log_size
=
log_buf_size
;
attr
.
log_level
=
log_buf
?
1
:
0
;
attr
.
kern_version
=
kern_version
;
if
(
log_buf
)
...
...
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