Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include math.h #include <math.h> on kernel source file?

I am trying to include math.h in my Linux kernel module. If I use,

#include '/usr/include/math.h'

It give me theses errors:

error: features.h: No such file or directory
error: bits/huge_val.h: No such file or directory
error: bits/mathdef.h: No such file or directory
error: bits/mathcalls.h: No such file or directory

Why is this?

like image 955
Madni Avatar asked Jun 18 '09 13:06

Madni


People also ask

What is included in math H?

h is a header file in the standard library of the C programming language designed for basic mathematical operations. Most of the functions involve the use of floating point numbers.

Is math H included by default?

It should be available by default; all you need is #include <math. h> , and the compiler will know where to find it. (So your title is a little misleading.) The functions declared in <math.

What does include math h do in C?

The C <math. h> header file declares a set of functions to perform mathematical operations such as: sqrt() to calculate the square root, log() to find natural logarithm of a number etc.

How do you use math h in C++?

In order to use these functions you need to include header file- <math. h> or <cmath>. double sin(double) : This function takes angle (in radian) as an argument and return its sine value that could be verified using sine curve.


2 Answers

You cannot use the C library in a kernel module, this is even more true for the math library part.

like image 184
David Cournapeau Avatar answered Sep 21 '22 12:09

David Cournapeau


You can't include a userspace C module in kernel space. Also are you sure that you want to be doing this? This thread may help http://kerneltrap.org/node/16570. You can do math functions inside the kernel, just search around on http://lxr.linux.no/ for the function you need.

like image 36
Sweeney Avatar answered Sep 22 '22 12:09

Sweeney