blob: 5dc08372cacbf6a51921a9d61a491f1230f37c94 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/* Public domain. */
#ifndef _LINUX_LOG2_H
#define _LINUX_LOG2_H
#include <sys/types.h>
#include <sys/systm.h>
#define ilog2(x) ((sizeof(x) <= 4) ? (fls(x) - 1) : (flsl(x) - 1))
int drm_order(unsigned long);
#define is_power_of_2(x) (((x) != 0) && (((x) - 1) & (x)) == 0)
#define order_base_2(x) drm_order(x)
static inline unsigned long
roundup_pow_of_two(unsigned long x)
{
return (1UL << flsl(x - 1));
}
static inline unsigned long
rounddown_pow_of_two(unsigned long x)
{
return (1UL << (flsl(x) - 1));
}
#endif
|