Commit 32109bf9 authored by Brenden Blanco's avatar Brenden Blanco

Include libbpf.h in some places, cleanup constants

Signed-off-by: default avatarBrenden Blanco <bblanco@plumgrid.com>
parent fdb0ace2
......@@ -25,9 +25,7 @@
#include "b_frontend_action.h"
extern "C"
int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size,
int max_entries);
#include "libbpf.h"
namespace ebpf {
......@@ -90,7 +88,7 @@ bool BTypeVisitor::VisitFunctionDecl(FunctionDecl *D) {
// put each non-static non-inline function decl in its own section, to be
// extracted by the MemoryManager
if (D->isExternallyVisible() && D->hasBody()) {
string attr = string("__attribute__((section(\".bpf.fn.") + D->getName().str() + "\")))\n";
string attr = string("__attribute__((section(\"") + BPF_FN_PREFIX + D->getName().str() + "\")))\n";
rewriter_.InsertText(D->getLocStart(), attr);
// remember the arg names of the current function...first one is the ctx
fn_args_.clear();
......
......@@ -63,6 +63,7 @@
#include "b_frontend_action.h"
#include "bpf_module.h"
#include "kbuild_helper.h"
#include "libbpf.h"
namespace ebpf {
......
......@@ -38,9 +38,7 @@
#include "cc/lexer.h"
#include "cc/type_helper.h"
#include "linux/bpf.h"
extern "C"
int bpf_create_map(int map_type, int key_size, int value_size, int max_entries);
#include "libbpf.h"
namespace ebpf {
namespace cc {
......@@ -801,7 +799,7 @@ StatusTuple CodegenLLVM::visit_table_index_expr_node(TableIndexExprNode *n) {
// result = lookup(key)
Value *lookup1 = B.CreateBitCast(B.CreateCall(lookup_fn, vector<Value *>({pseudo_map_fd, key_ptr})), leaf_ptype);
Value *result;
Value *result = nullptr;
if (n->table_->policy_id()->name_ == "AUTO") {
Function *parent = B.GetInsertBlock()->getParent();
BasicBlock *label_start = B.GetInsertBlock();
......@@ -1079,7 +1077,7 @@ StatusTuple CodegenLLVM::visit_table_decl_stmt_node(TableDeclStmtNode *n) {
auto leaf = scopes_->top_struct()->lookup(n->leaf_id()->name_, /*search_local*/true);
if (!leaf) return mkstatus_(n, "cannot find leaf %s", n->leaf_id()->name_.c_str());
int map_type = BPF_MAP_TYPE_UNSPEC;
bpf_map_type map_type = BPF_MAP_TYPE_UNSPEC;
if (n->type_id()->name_ == "FIXED_MATCH")
map_type = BPF_MAP_TYPE_HASH;
else if (n->type_id()->name_ == "INDEXED")
......
......@@ -37,8 +37,6 @@ class StructType;
class SwitchInst;
}
#define BPF_FN_PREFIX ".bpf.fn."
namespace ebpf {
namespace cc {
......
......@@ -49,6 +49,10 @@ int bpf_detach_kprobe(const char *event_desc);
#define LOG_BUF_SIZE 65536
extern char bpf_log_buf[LOG_BUF_SIZE];
// Put non-static/inline functions in their own section with this prefix +
// fn_name to enable discovery by the bcc library.
#define BPF_FN_PREFIX ".bpf.fn."
/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */
#define BPF_ALU64_REG(OP, DST, SRC) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment