From 044996685258c69e120de7198b3cfbb96faa50ba Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 22 Aug 2007 17:05:41 +0000 Subject: [PATCH] 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 --- src/pulsecore/core-util.c | 18 ------------------ src/pulsecore/core-util.h | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 0005e22..2c5a32e 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -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; -} diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h index 29dc2fb..ea571e7 100644 --- a/src/pulsecore/core-util.h +++ b/src/pulsecore/core-util.h @@ -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 -- 2.7.4