Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
PPSi
Commits
ea6042b4
Commit
ea6042b4
authored
Nov 04, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
diag.c: calculate a magic number at build time
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
6eb9e1bd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
diag.c
diag.c
+6
-1
No files found.
diag.c
View file @
ea6042b4
...
...
@@ -7,6 +7,10 @@
#include <stdarg.h>
#include <ppsi/ppsi.h>
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#endif
static
char
*
thing_name
[]
=
{
[
pp_dt_fsm
]
=
"diag-fsm"
,
[
pp_dt_time
]
=
"diag-time"
,
...
...
@@ -59,8 +63,9 @@ unsigned long pp_diag_parse(char *diaglevel)
{
unsigned
long
res
=
0
;
int
i
=
28
;
/* number of bits to shift the nibble: 28..31 is first */
int
nthings
=
ARRAY_SIZE
(
thing_name
);
while
(
*
diaglevel
&&
i
>=
4
)
{
while
(
*
diaglevel
&&
i
>=
(
32
-
4
*
nthings
)
)
{
if
(
*
diaglevel
<
'0'
||
*
diaglevel
>
'3'
)
break
;
res
|=
((
*
diaglevel
-
'0'
)
<<
i
);
...
...
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