Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
ce81312d
Commit
ce81312d
authored
Jun 15, 2014
by
Paul Sokolovsky
Browse files
misc: Add count_lead_ones() function, useful for UTF-8 handling.
parent
63143c94
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/misc.h
View file @
ce81312d
...
...
@@ -166,4 +166,17 @@ int DEBUG_printf(const char *fmt, ...);
extern
uint
mp_verbose_flag
;
// This is useful for unicode handling. Some CPU archs has
// special instructions for efficient implentation of this
// function (e.g. CLZ on ARM).
#ifndef count_lead_ones
static
inline
uint
count_lead_ones
(
byte
val
)
{
uint
c
=
0
;
for
(
byte
mask
=
0x80
;
val
&
mask
;
mask
>>=
1
)
{
c
++
;
}
return
c
;
}
#endif
#endif // _INCLUDED_MINILIB_H
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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