8f6c61bcef
Includes some common routines which may be used by other drivers. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8405 a95241bf-73f2-0310-859d-f6bbb57e9c96
49 lines
699 B
C
49 lines
699 B
C
/*
|
|
Copyright (c) 2002/03, Thomas Kurschel
|
|
|
|
|
|
Part of Radeon accelerant
|
|
|
|
Utility functions
|
|
*/
|
|
|
|
#ifndef _UTILS_H
|
|
#define _UTILS_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
extern int log2( uint32 x );
|
|
|
|
static inline int RoundDiv( int num, int den )
|
|
{
|
|
return (num + (den / 2)) / den;
|
|
}
|
|
|
|
static inline int32 RoundDiv64( int64 num, int32 den )
|
|
{
|
|
return (num + (den / 2)) / den;
|
|
}
|
|
|
|
static inline int ceilShiftDiv( int num, int shift )
|
|
{
|
|
return (num + (1 << shift) - 1) >> shift;
|
|
}
|
|
|
|
static inline int ceilDiv( int num, int den )
|
|
{
|
|
return (num + den - 1) / den;
|
|
}
|
|
|
|
// macros for fixed-point calculation
|
|
#define FIX_SHIFT 32
|
|
#define FIX_SCALE (1LL << FIX_SHIFT)
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|