Files
codezero/conts/userlibs/libl4/include/l4lib/linux/lib/math.h
Bahadir Balban 6fa4884a5a Changes since April
Clean up of build directories.
Simplifications to capability model.
2010-06-01 15:08:13 +03:00

45 lines
789 B
C

#ifndef __LIB_MATH_H__
#define __LIB_MATH_H__
#if !defined (__LINUX_CONTAINER__)
#if !defined pow
static inline int pow(int val, int exp)
{
int res = 1;
for (int i = 0; i < exp; i++)
res *= val;
return res;
}
#endif
#if !defined min
static inline int min(int x, int y)
{
return x < y ? x : y;
}
static inline int max(int x, int y)
{
return x > y ? x : y;
}
#endif
#endif /* !__LINUX_CONTAINER__ */
/* Tests if ranges a-b intersect with range c-d */
static inline int set_intersection(unsigned long a, unsigned long b,
unsigned long c, unsigned long d)
{
/*
* Below is the complement set (') of the intersection
* of 2 ranges, much simpler ;-)
*/
if (b <= c || a >= d)
return 0;
/* The rest is always intersecting */
return 1;
}
#endif /* __LIB_MATH_H__ */