-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from jpsamaroo/jps/bpfcall
Add bpfcall and runtime buffers
- Loading branch information
Showing
14 changed files
with
374 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "BPFnative" | ||
uuid = "b6338580-32ea-11e9-1791-33a79977d8c4" | ||
authors = ["Julian P Samaroo <[email protected]>"] | ||
version = "0.1.1" | ||
version = "0.1.2" | ||
|
||
[deps] | ||
CBinding = "d43a6710-96b8-4a2d-833c-c424785e5374" | ||
|
@@ -15,7 +15,7 @@ Preferences = "21216c6a-2e73-6563-6e65-726566657250" | |
[compat] | ||
CBinding = "1" | ||
GPUCompiler = "0.9.1" | ||
LLVM = "= 3.4" | ||
LLVM = "3.6" | ||
Libbpf_jll = "0.3" | ||
Preferences = "1" | ||
julia = "1.6" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export bpfcall | ||
|
||
@generated function _bpfcall(::Val{cmd}, ::Type{rettype}, ::Type{argtypes}, args::Vararg{Any}) where {cmd,rettype,argtypes} | ||
JuliaContext() do ctx | ||
T_ret = convert(LLVMType, rettype, ctx) | ||
T_args = map(x->convert(LLVMType, x, ctx), argtypes.parameters) | ||
|
||
llvm_f, _ = create_function(T_ret, LLVMType[T_args...]) | ||
mod = LLVM.parent(llvm_f) | ||
|
||
Builder(ctx) do builder | ||
entry = BasicBlock(llvm_f, "entry", ctx) | ||
position!(builder, entry) | ||
ft = LLVM.FunctionType(T_ret, LLVMType[T_args...]) | ||
ftp = LLVM.PointerType(ft) | ||
f = inttoptr!(builder, ConstantInt(cmd, ctx), ftp) | ||
value = call!(builder, f, LLVM.Value[parameters(llvm_f)...]) | ||
ret!(builder, value) | ||
end | ||
call_function(llvm_f, rettype, Base.to_tuple_type(args), :((args...,))) | ||
end | ||
end | ||
@inline bpfcall(cmd::API.BPFHelper, RT, AT, args...) = | ||
_bpfcall(Val(Int(cmd)), RT, AT, args...) | ||
@inline bpfcall(cmd::API.BPFHelper, RT) = _bpfcall(Val(Int(cmd)), RT, Tuple{}) | ||
@inline bpfcall(cmd::API.BPFHelper) = _bpfcall(Val(Int(cmd)), Cvoid, Tuple{}) |
Oops, something went wrong.
e4d5d1c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register()
e4d5d1c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/34189
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: