mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
make pa_make_power_of_two() and pa_is_power_of_two() inline functions
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1698 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
190648a3ed
commit
0449966852
2 changed files with 17 additions and 20 deletions
|
|
@ -1208,21 +1208,3 @@ char *pa_truncate_utf8(char *c, size_t l) {
|
|||
|
||||
return c;
|
||||
}
|
||||
|
||||
int pa_is_power_of_two(unsigned n) {
|
||||
return !(n & (n - 1));
|
||||
}
|
||||
|
||||
unsigned pa_make_power_of_two(unsigned n) {
|
||||
unsigned j = n;
|
||||
|
||||
if (pa_is_power_of_two(n))
|
||||
return n;
|
||||
|
||||
while (j) {
|
||||
j = j >> 1;
|
||||
n = n | j;
|
||||
}
|
||||
|
||||
return n + 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,22 @@ int pa_snprintf(char *str, size_t size, const char *format, ...);
|
|||
|
||||
char *pa_truncate_utf8(char *c, size_t l);
|
||||
|
||||
int pa_is_power_of_two(unsigned n);
|
||||
unsigned pa_make_power_of_two(unsigned n);
|
||||
static inline int pa_is_power_of_two(unsigned n) {
|
||||
return !(n & (n - 1));
|
||||
}
|
||||
|
||||
static inline unsigned pa_make_power_of_two(unsigned n) {
|
||||
unsigned j = n;
|
||||
|
||||
if (pa_is_power_of_two(n))
|
||||
return n;
|
||||
|
||||
while (j) {
|
||||
j = j >> 1;
|
||||
n = n | j;
|
||||
}
|
||||
|
||||
return n + 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue