mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Richard B. Johnson" <root@chaos.analogic.com>
To: VINOD GOPAL <vinod_gopal74@yahoo.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: arithmetic functions for linux driver
Date: Wed, 17 Mar 2004 13:36:59 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.53.0403171317430.19593@chaos> (raw)
In-Reply-To: <20040317175939.75460.qmail@web60705.mail.yahoo.com>

On Wed, 17 Mar 2004, VINOD GOPAL wrote:

> Hi,
>  I am new to linux world and this mailing list.
>
>  I need to use the arithmetic functions like sin, cos,
> exp, log, etc in linux device driver.
>
>  On search read , not to use libm from kernel driver
> as it will harm the fpu registers.
>
>   Do you have any insight how to support these
> functions in linux driver or any code that is
> available which I can make use of?
>
> thanks
> vinod

There are at least three problems.
(1) The kernel does not save and restore FPU registers across
system calls, only context-switches. This means that you will
probably break some user-mode code that is using the FPU.
You could, of course, save then restore the FPU state in your
code. However, there are other problems, read on.

(2) Some versions of the GCC compiler rely on the floating-
point library and do not generate FPU instructions in-line.
You absolutely-positively cannot link your kernel code against
such a library. The shared libraries don't even exist from
within the kernel, and the static library assumes user-mode
code.

(3) The use of FP within the kernel means that you have
lost the reason for a kernel module. Any such code must
execute in user-mode. The Unix/Linux way involves a
task called a daemon. Such a task does all the user-mode
stuff like floating-point math and file-I/O. It interfaces
with your driver either through the POSIX API (open/close/read/write),
/proc, or sockets.

A Unix/Linux "driver" is NOT anything like a Windows "driver".
Most Windows drivers are not drivers at all, but Libraries!
Such Libraries run in user-mode. Making such a library
in Linux is easy, just compile your library-code and link
against it. You can use any resources other user-mode code
can use.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
            Note 96.31% of all statistics are fiction.



  parent reply	other threads:[~2004-03-17 18:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-17 10:44 Linux 2.4.25, nfs client hangs when talking to a MacOS nfs server Charles-Edouard Ruault
2004-03-17 16:58 ` Trond Myklebust
2004-03-17 17:41   ` Charles-Edouard Ruault
2004-03-17 17:59     ` arithmetic functions for linux driver VINOD GOPAL
2004-03-17 18:11       ` John Bradford
2004-03-17 18:15         ` VINOD GOPAL
2004-03-17 18:50           ` Richard B. Johnson
2004-03-17 20:27             ` John Bradford
2004-03-17 18:17       ` Chris Friesen
2004-03-17 18:36       ` Richard B. Johnson [this message]
2004-03-17 23:21       ` Peter Williams

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=Pine.LNX.4.53.0403171317430.19593@chaos \
    --to=root@chaos.analogic.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vinod_gopal74@yahoo.com \
    /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

all inboxes | Powered by JetHome®