blob: 6200f1c59051df855ece7c3ff48e2b4b553407e6 [file] [log] [blame]
#ifndef STDLIB_H
#define STDLIB_H
#include <stddef.h>
#define min(a,b) MIN((a),(b))
#define max(a,b) MAX((a),(b))
void *memalign(size_t boundary, size_t size);
void *malloc(size_t size);
/* We never free memory */
static inline void free(void *ptr) {}
#ifndef __ROMCC__
static inline unsigned long div_round_up(unsigned int n, unsigned int d)
{
return (n + d - 1) / d;
}
/*
* Divide positive or negative dividend by positive divisor and round
* to closest integer. Result is undefined for negative divisors and
* for negative dividends if the divisor variable type is unsigned.
*/
#define DIV_ROUND_CLOSEST(x, divisor)( \
{ \
typeof(x) __x = x; \
typeof(divisor) __d = divisor; \
(((typeof(x))-1) > 0 || \
((typeof(divisor))-1) > 0 || (__x) > 0) ? \
(((__x) + ((__d) / 2)) / (__d)) : \
(((__x) - ((__d) / 2)) / (__d)); \
} \
)
#endif
#endif /* STDLIB_H */