public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nuno Santos <nsantos@edigma.com>
To: linux-kernel@vger.kernel.org
Subject: Floating point usage inside kernel
Date: Fri, 25 Nov 2011 11:14:39 +0000	[thread overview]
Message-ID: <4ECF789F.3040001@edigma.com> (raw)
In-Reply-To: <S1754322Ab1KYK6W/20111125105822Z+929@vger.kernel.org>

Hi,

This question has probably bean discussed for several times in this list 
but the information I found googling around is inconclusive to me.

I'm implementing a kernel input driver and I have successfully achieved 
my goal for at least 75%.

Since I understand that kernel floating point usage is discouraged I 
have converted most of my code to use integers. I knew that kernel 
floating point usage was already discouraged in Windows but could be 
done by saving floating point unit state.

However, there is a small part of my code that really needs floating 
point calculations and it's conversion to integer is not being trivial.

Since that part of the code is not done intensively and since I have 
already found information that leads me to believe that the same is 
possible, that is, saving fpu state and successfully achieve floating 
point calculation on kernel.

I found this article on the internet which deeply explains fpu usage in 
kernel:

http://www.linuxsmiths.com/blog/?p=253

As a conclusion, the article says that if we need to use floating point 
calculations in kernel, it is possible if we keep the state of the fpu 
unit with the following calls:

*/kernel_fpu_begin()
/**/kernel_fpu_end()

We also need to use the compiler flag -mhard-float

But when I compile I get:

error: implicit declaration of function ‘kernel_fpu_begin’ 
[-Werror=implicit-function-declaration]
error: implicit declaration of function ‘kernel_fpu_end’ 
[-Werror=implicit-function-declaration]

Doing a grep -r kernel_fpu_begin * on kernel source dir I can find 
several references to this functions but not them is included in the 
include dir. Which include do I need to have this functions found in 
compile time?

Am I even sailing in the right direction? Is this really possible or am 
I wasting my time?

I'm new to kernel programming and this is not a trivial issue for me. I 
hope you understand.

Thanks,

With my best regards,

Nuno Santos
/*

       reply	other threads:[~2011-11-25 11:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <S1754322Ab1KYK6W/20111125105822Z+929@vger.kernel.org>
2011-11-25 11:14 ` Nuno Santos [this message]
2011-11-25 12:08   ` Floating point usage inside kernel Jiri Slaby
2011-11-25 16:16     ` Nuno Santos
2011-11-25 17:05       ` Paulo Marques
2011-11-25 17:46         ` Nuno Santos
2011-11-25 18:10           ` Paulo Marques
2011-11-28 10:11             ` Nuno Santos
2011-11-28 12:50               ` Paulo Marques
2011-11-28  4:00       ` Andy Lutomirski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ECF789F.3040001@edigma.com \
    --to=nsantos@edigma.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox