Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
5c48e158
Commit
5c48e158
authored
Jan 28, 2013
by
Benoit Rat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libswitchhw: add function to display binary patterns
parent
612a766c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
util.h
userspace/include/util.h
+1
-0
util.c
userspace/libswitchhw/util.c
+18
-0
No files found.
userspace/include/util.h
View file @
5c48e158
...
...
@@ -9,5 +9,6 @@
void
shw_udelay
(
uint32_t
microseconds
);
void
*
shw_malloc
(
size_t
nbytes
);
void
shw_free
(
void
*
ptr
);
const
char
*
shw_2binary
(
uint8_t
x
);
#endif
userspace/libswitchhw/util.c
View file @
5c48e158
...
...
@@ -45,3 +45,21 @@ uint64_t shw_get_tics()
gettimeofday
(
&
tv
,
&
tz
);
return
(
uint64_t
)
tv
.
tv_usec
+
(
uint64_t
)
tv
.
tv_sec
*
1000000ULL
;
}
const
char
*
shw_2binary
(
uint8_t
x
)
{
static
char
b
[
9
];
int
z
;
char
*
p
=
b
;
for
(
z
=
0x80
;
z
>
0
;
z
>>=
1
)
{
*
p
++=
(((
x
&
z
)
==
z
)
?
'1'
:
'0'
);
}
*
p
=
'\0'
;
return
b
;
}
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