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
8f63810f
Commit
8f63810f
authored
Sep 21, 2015
by
Brendan Gregg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add bpf_log2 functions
parent
d9e578b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
src/cc/export/helpers.h
src/cc/export/helpers.h
+22
-0
No files found.
src/cc/export/helpers.h
View file @
8f63810f
...
...
@@ -185,6 +185,28 @@ static inline void bpf_store_dword(void *skb, u64 off, u64 val) {
#define MASK(_n) ((_n) < 64 ? (1ull << (_n)) - 1 : ((u64)-1LL))
#define MASK128(_n) ((_n) < 128 ? ((unsigned __int128)1 << (_n)) - 1 : ((unsigned __int128)-1))
static
unsigned
int
bpf_log2
(
unsigned
int
v
)
{
unsigned
int
r
;
unsigned
int
shift
;
r
=
(
v
>
0xFFFF
)
<<
4
;
v
>>=
r
;
shift
=
(
v
>
0xFF
)
<<
3
;
v
>>=
shift
;
r
|=
shift
;
shift
=
(
v
>
0xF
)
<<
2
;
v
>>=
shift
;
r
|=
shift
;
shift
=
(
v
>
0x3
)
<<
1
;
v
>>=
shift
;
r
|=
shift
;
r
|=
(
v
>>
1
);
return
r
;
}
static
unsigned
int
bpf_log2l
(
unsigned
long
v
)
{
unsigned
int
hi
=
v
>>
32
;
if
(
hi
)
return
bpf_log2
(
hi
)
+
32
+
1
;
else
return
bpf_log2
(
v
)
+
1
;
}
struct
bpf_context
;
static
inline
__attribute__
((
always_inline
))
...
...
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