I need to drop CEIL macro used in kernel module and use a ceil function in kernel to replace the caller of the macro.
I tried replacing ceil function in reference to Linux manual page
http://man7.org/linux/man-pages/man3/ceil.3.html#DESCRIPTION.
My question is whether it is possible to convert this macro into in kernel function i.e. ceil or not? Also, here in the code variable 'o' and 'rsz' are declared as unsigned int, where as ceil function's return type is double. If it's possible, how can I change it?
#define CEIL(a, b) (((a) + (b-1)) / (b))
o += (((CEIL(rsz, 1024)) << 1) << n);
On editing above code to
o += ((ceil(rsz) << 1) << n)
Also, I tried including math header in .c file, which is
# include <math.h>
On executing, it gives a compilation error
fatal error: math.h: No such file or directory
ceilfunction in<math.h>is for floating-pointdouble, but theCEILmacro you show is for integers. Do you need a floating-point ceiling function or an integer ceiling function? There is certainly no reason you could not use an integer ceiling function in kernel code. Whatever compilation error you got is from something wrong with the code, not from trying to calculate the ceiling of a ratio. (c) You should show enough code that somebody else could compile it and see the error for themselves. - Eric Postpischil