xref: /haiku/headers/private/graphics/radeon/utils.h (revision 002f37b0cca92e4cf72857c72ac95db5a8b09615)
1 /*
2 	Copyright (c) 2002/03, Thomas Kurschel
3 
4 
5 	Part of Radeon accelerant
6 
7 	Utility functions
8 */
9 
10 #ifndef _UTILS_H
11 #define _UTILS_H
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 
18 extern int radeon_log2( uint32 x );
19 
20 static inline int RoundDiv( int num, int den )
21 {
22 	return (num + (den / 2)) / den;
23 }
24 
25 static inline int32 RoundDiv64( int64 num, int32 den )
26 {
27 	return (num + (den / 2)) / den;
28 }
29 
30 static inline int ceilShiftDiv( int num, int shift )
31 {
32 	return (num + (1 << shift) - 1) >> shift;
33 }
34 
35 static inline int ceilDiv( int num, int den )
36 {
37 	return (num + den - 1) / den;
38 }
39 
40 // macros for fixed-point calculation
41 #define FIX_SHIFT 32
42 #define FIX_SCALE (1LL << FIX_SHIFT)
43 
44 #ifdef __cplusplus
45 }
46 #endif
47 
48 #endif
49