Merge pull request #10 from hanyunqi/is_power2

Update function is_power2 in shared_func.c
pull/12/head
YuQing 2016-12-17 09:52:45 +08:00 committed by GitHub
commit 182ad4b72a
1 changed files with 2 additions and 10 deletions

View File

@ -2306,17 +2306,9 @@ int64_t get_current_time_us()
return ((int64_t)tv.tv_sec * 1000 * 1000 + (int64_t)tv.tv_usec); return ((int64_t)tv.tv_sec * 1000 * 1000 + (int64_t)tv.tv_usec);
} }
bool is_power2(const int64_t n) inline bool is_power2(const int64_t n)
{ {
int64_t i; return ((n != 0) && !(n & (n - 1)));
i = 2;
while (i < n)
{
i *= 2;
}
return i == n;
} }
static inline int do_lock_file(int fd, int cmd, int type) static inline int do_lock_file(int fd, int cmd, int type)