xref: /haiku/src/add-ons/kernel/drivers/graphics/radeon/utils.c (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
1 /*
2 	Copyright (c) 2002, Thomas Kurschel
3 
4 
5 	Part of Radeon driver
6 
7 	some utility functions
8 */
9 
10 #include "OS.h"
11 #include "utils.h"
12 
13 // get ceil( log2( size ))
14 int radeon_log2( uint32 x )
15 {
16 	int res;
17 	uint32 tmp;
18 
19 	for( res = 0, tmp = x ; tmp > 1 ; ++res )
20 		tmp >>= 1;
21 
22 	if( (x & ((1 << res) - 1)) != 0 )
23 		++res;
24 
25 	return res;
26 }
27