public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Problems compiling kernel modules
@ 2004-08-21 19:24 Lei Yang
  2004-08-21 21:44 ` Sam Ravnborg
  0 siblings, 1 reply; 21+ messages in thread
From: Lei Yang @ 2004-08-21 19:24 UTC (permalink / raw)
  To: Kernel Newbies Mailing List, linux-kernel

Hi all,

I was trying to compile a kernel module with kbuild. The module 'test.c' 
include a header file 'fred.h' and there is a "#include <stdio.h>" in 
'fred.h'.

Makefile looks like:

------------------------------------------------------------------------
ifneq ($(KERNELRELEASE),)
obj-m       := test.o

else
KDIR        := /usr/src/linux
PWD         := $(shell pwd)

default:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
	

clean:
	rm -f *.o *.ko *.mod.c *.mod.o \
	.test.o.cmd .test.ko.cmd .test.mod.o.cmd
	rm -rf .tmp_versions
endif

-------------------------------------------------------------------------
But upon compiling, there would be errors like this:
In file included from /home/lei/test.c:49:
/home/lei/fred.h:4:19: stdio.h: No such file or directory

and a lot of undeclared names follow which I assume is from stdio.h.

Could anyone point out what's wrong here?

TIA!

Lei

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-21 21:44 ` Sam Ravnborg
@ 2004-08-21 19:45   ` Lei Yang
  2004-08-21 20:05     ` viro
                       ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Lei Yang @ 2004-08-21 19:45 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Kernel Newbies Mailing List, linux-kernel

Sam Ravnborg wrote:
> On Sat, Aug 21, 2004 at 03:24:12PM -0400, Lei Yang wrote:
> 
>>Hi all,
>>
>>I was trying to compile a kernel module with kbuild. The module 'test.c' 
>>include a header file 'fred.h' and there is a "#include <stdio.h>" in 
>>'fred.h'.
>>
>>Makefile looks like:
>>
>>------------------------------------------------------------------------
>>ifneq ($(KERNELRELEASE),)
>>obj-m       := test.o
>>
>>else
>>KDIR        := /usr/src/linux
>>PWD         := $(shell pwd)
>>
>>default:
>>	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
>>	
>>
>>clean:
> 
> For 2.6.7 (or 2.6.6) you do not need to specify your own clean: rule.
> 
> 
>>But upon compiling, there would be errors like this:
>>In file included from /home/lei/test.c:49:
>>/home/lei/fred.h:4:19: stdio.h: No such file or directory
> 
> The kernel does not provide you with a stdio.h header, so therefore you
> cannot find it neither use functionality from it.

You mean I can't use stdio.h at all?

But what if I really need to? Is there anything I can do?

> 	Sam

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-21 21:50     ` Sam Ravnborg
@ 2004-08-21 19:55       ` Lei Yang
  2004-08-21 20:46       ` Lei Yang
  1 sibling, 0 replies; 21+ messages in thread
From: Lei Yang @ 2004-08-21 19:55 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Kernel Newbies Mailing List, linux-kernel

Sam Ravnborg wrote:
> On Sat, Aug 21, 2004 at 03:45:38PM -0400, Lei Yang wrote:
> 
>>You mean I can't use stdio.h at all?
> 
> Correct.
> 
>>But what if I really need to? Is there anything I can do?
> 
> Try to explain what you need. Then maybe someone on the list can help you.

I need to do File I/O operation and I need to use streams.

Thanks,
Lei

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-21 19:45   ` Lei Yang
@ 2004-08-21 20:05     ` viro
  2004-08-21 20:13     ` Lee Revell
  2004-08-21 21:50     ` Sam Ravnborg
  2 siblings, 0 replies; 21+ messages in thread
From: viro @ 2004-08-21 20:05 UTC (permalink / raw)
  To: Lei Yang; +Cc: Sam Ravnborg, Kernel Newbies Mailing List, linux-kernel

On Sat, Aug 21, 2004 at 03:45:38PM -0400, Lei Yang wrote:
> You mean I can't use stdio.h at all?

Not in the kernel code.
 
> But what if I really need to?

Then you are really out of luck.

> Is there anything I can do?

A lot of things - hopefully your life is not reduced to trying to write
stdio-dependent kernel modules...

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-21 19:45   ` Lei Yang
  2004-08-21 20:05     ` viro
@ 2004-08-21 20:13     ` Lee Revell
  2004-08-21 21:50     ` Sam Ravnborg
  2 siblings, 0 replies; 21+ messages in thread
From: Lee Revell @ 2004-08-21 20:13 UTC (permalink / raw)
  To: Lei Yang; +Cc: Sam Ravnborg, Kernel Newbies Mailing List, linux-kernel

On Sat, 2004-08-21 at 15:45, Lei Yang wrote:

> You mean I can't use stdio.h at all?
> 
> But what if I really need to?

LOL, the above needs to go in the FAQ.

Lee


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-21 21:50     ` Sam Ravnborg
  2004-08-21 19:55       ` Lei Yang
@ 2004-08-21 20:46       ` Lei Yang
  2004-08-21 20:57         ` Lee Revell
  2004-08-21 21:11         ` Alex Goddard
  1 sibling, 2 replies; 21+ messages in thread
From: Lei Yang @ 2004-08-21 20:46 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Kernel Newbies Mailing List, linux-kernel

What about multi-file module?

Say test.c doesn't include stdio.h, while there is some other .c file 
which is to be compiled and linked into test.ko, include stdio?

Would that work?

TIA!
Lei
Sam Ravnborg wrote:
> On Sat, Aug 21, 2004 at 03:45:38PM -0400, Lei Yang wrote:
> 
>>You mean I can't use stdio.h at all?
> 
> Correct.
> 
>>But what if I really need to? Is there anything I can do?
> 
> Try to explain what you need. Then maybe someone on the list can help you.
> 
> 	Sam

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-21 20:46       ` Lei Yang
@ 2004-08-21 20:57         ` Lee Revell
  2004-08-23 14:10           ` Lei Yang
  2004-08-21 21:11         ` Alex Goddard
  1 sibling, 1 reply; 21+ messages in thread
From: Lee Revell @ 2004-08-21 20:57 UTC (permalink / raw)
  To: Lei Yang; +Cc: Sam Ravnborg, Kernel Newbies Mailing List, linux-kernel

On Sat, 2004-08-21 at 16:46, Lei Yang wrote:
> What about multi-file module?
> 
> Say test.c doesn't include stdio.h, while there is some other .c file 
> which is to be compiled and linked into test.ko, include stdio?
> 
> Would that work?
> 

Are you just trying to print from a kernel module?  Use printk.

The kernel does not really have its own standard input and standard
output - the kernel manages those things for processes.

Lee


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-21 20:46       ` Lei Yang
  2004-08-21 20:57         ` Lee Revell
@ 2004-08-21 21:11         ` Alex Goddard
  1 sibling, 0 replies; 21+ messages in thread
From: Alex Goddard @ 2004-08-21 21:11 UTC (permalink / raw)
  To: Lei Yang; +Cc: Sam Ravnborg, Kernel Newbies Mailing List, linux-kernel

On Sat, 21 Aug 2004, Lei Yang wrote:

> What about multi-file module?
>
> Say test.c doesn't include stdio.h, while there is some other .c file which 
> is to be compiled and linked into test.ko, include stdio?
>
> Would that work?
>
> TIA!
> Lei

You can't use userspace headers in the kernel.  That's why the kernel has 
its own set with things like printk(), etc, etc.  What is it that you're 
trying to do and why does it need file i/o?

-- 
Alex Goddard
agoddard at purdue dot edu

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-21 19:24 Problems compiling kernel modules Lei Yang
@ 2004-08-21 21:44 ` Sam Ravnborg
  2004-08-21 19:45   ` Lei Yang
  0 siblings, 1 reply; 21+ messages in thread
From: Sam Ravnborg @ 2004-08-21 21:44 UTC (permalink / raw)
  To: Lei Yang; +Cc: Kernel Newbies Mailing List, linux-kernel

On Sat, Aug 21, 2004 at 03:24:12PM -0400, Lei Yang wrote:
> Hi all,
> 
> I was trying to compile a kernel module with kbuild. The module 'test.c' 
> include a header file 'fred.h' and there is a "#include <stdio.h>" in 
> 'fred.h'.
> 
> Makefile looks like:
> 
> ------------------------------------------------------------------------
> ifneq ($(KERNELRELEASE),)
> obj-m       := test.o
> 
> else
> KDIR        := /usr/src/linux
> PWD         := $(shell pwd)
> 
> default:
> 	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
> 	
> 
> clean:
For 2.6.7 (or 2.6.6) you do not need to specify your own clean: rule.

> But upon compiling, there would be errors like this:
> In file included from /home/lei/test.c:49:
> /home/lei/fred.h:4:19: stdio.h: No such file or directory
The kernel does not provide you with a stdio.h header, so therefore you
cannot find it neither use functionality from it.

	Sam

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-21 19:45   ` Lei Yang
  2004-08-21 20:05     ` viro
  2004-08-21 20:13     ` Lee Revell
@ 2004-08-21 21:50     ` Sam Ravnborg
  2004-08-21 19:55       ` Lei Yang
  2004-08-21 20:46       ` Lei Yang
  2 siblings, 2 replies; 21+ messages in thread
From: Sam Ravnborg @ 2004-08-21 21:50 UTC (permalink / raw)
  To: Lei Yang; +Cc: Sam Ravnborg, Kernel Newbies Mailing List, linux-kernel

On Sat, Aug 21, 2004 at 03:45:38PM -0400, Lei Yang wrote:
> 
> You mean I can't use stdio.h at all?
Correct.
> 
> But what if I really need to? Is there anything I can do?
Try to explain what you need. Then maybe someone on the list can help you.

	Sam

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-21 20:57         ` Lee Revell
@ 2004-08-23 14:10           ` Lei Yang
  2004-08-23 14:29             ` Richard B. Johnson
  0 siblings, 1 reply; 21+ messages in thread
From: Lei Yang @ 2004-08-23 14:10 UTC (permalink / raw)
  To: Lee Revell; +Cc: Sam Ravnborg, Kernel Newbies Mailing List, linux-kernel

Hi friends,

I've askeed questions about errors compiling kernel modules caused by 
including <stdio.h> and got some very helpful info here.

I changed those I/O stream and file operation in the code and get the 
module compiled, however, there would be warnings like

In file included from /home/lei/modules/test.c:49:
/home/lei/modules/Kcomp.h:21: warning: function declaration isn't a 
prototype
/home/lei/modules/Kcomp.h:27: warning: function declaration isn't a 
prototype
/home/lei/modules/Kcomp.h:69: warning: function declaration isn't a 
prototype

And the no prototype fuction looks like

int preset() // with no arguments
{
	p = &nodes[0][0];
	return 0;
}


So when I tried to install the module with insmod ./test.ko ,
there would be an error,

insmod: error inserting './test.ko': -1 Unknown symbol in module

Could anyone tell me what is wrong here? Is that because of the no 
prototype function declaration?

TIA
Lei

Lee Revell wrote:
> On Sat, 2004-08-21 at 16:46, Lei Yang wrote:
> 
>>What about multi-file module?
>>
>>Say test.c doesn't include stdio.h, while there is some other .c file 
>>which is to be compiled and linked into test.ko, include stdio?
>>
>>Would that work?
>>
> 
> 
> Are you just trying to print from a kernel module?  Use printk.
> 
> The kernel does not really have its own standard input and standard
> output - the kernel manages those things for processes.
> 
> Lee
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-23 14:10           ` Lei Yang
@ 2004-08-23 14:29             ` Richard B. Johnson
  2004-08-23 14:39               ` Lei Yang
  2004-08-23 15:48               ` Andreas Schwab
  0 siblings, 2 replies; 21+ messages in thread
From: Richard B. Johnson @ 2004-08-23 14:29 UTC (permalink / raw)
  To: Lei Yang
  Cc: Lee Revell, Sam Ravnborg, Kernel Newbies Mailing List,
	linux-kernel

On Mon, 23 Aug 2004, Lei Yang wrote:

> Hi friends,
>
> I've askeed questions about errors compiling kernel modules caused by
> including <stdio.h> and got some very helpful info here.
>
> I changed those I/O stream and file operation in the code and get the
> module compiled, however, there would be warnings like
>
> In file included from /home/lei/modules/test.c:49:
> /home/lei/modules/Kcomp.h:21: warning: function declaration isn't a
> prototype
> /home/lei/modules/Kcomp.h:27: warning: function declaration isn't a
> prototype
> /home/lei/modules/Kcomp.h:69: warning: function declaration isn't a
> prototype
>
> And the no prototype fuction looks like
>
> int preset() // with no arguments
> {
> 	p = &nodes[0][0];
> 	return 0;
> }
>

A function looks like this:

int present()
{

}

A prototype for the same function looks like this:

int present(void);

Functions always have "{}". Prototypes never do.
-- Yes there's some troll who might cite some obscure
case... ignore them.

If you compile above a certain warning-level, then prototypes
are required. The prototype usually goes in header files
and the function (the actual code) goes in the source files.

>
> So when I tried to install the module with insmod ./test.ko ,
> there would be an error,
>
> insmod: error inserting './test.ko': -1 Unknown symbol in module
>
> Could anyone tell me what is wrong here? Is that because of the no
> prototype function declaration?
>

Do `depmod -e test.ko` to see what it's complaining about. You
can see all the symbols by using `nm`. Try it. Your code
probably didn't define the necessary stuff to make a module.
You need to look at a typical module (driver) that comes with the
kernel. Just find one of the shortest ".c" files in the driver
tree.


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



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-23 14:29             ` Richard B. Johnson
@ 2004-08-23 14:39               ` Lei Yang
  2004-08-23 14:52                 ` Richard B. Johnson
  2004-08-23 14:52                 ` Alan Cox
  2004-08-23 15:48               ` Andreas Schwab
  1 sibling, 2 replies; 21+ messages in thread
From: Lei Yang @ 2004-08-23 14:39 UTC (permalink / raw)
  To: root; +Cc: Lee Revell, Sam Ravnborg, Kernel Newbies Mailing List,
	linux-kernel

Richard B. Johnson wrote:

> Do `depmod -e test.ko` to see what it's complaining about. You
> can see all the symbols by using `nm`. Try it. Your code
> probably didn't define the necessary stuff to make a module.
> You need to look at a typical module (driver) that comes with the
> kernel. Just find one of the shortest ".c" files in the driver
> tree.

Thanks! I did less /var/log/messages, and got the unknown symbols
Unknown symbol __divsf3
Unknown symbol __fixsfsi
Unknown symbol __subsf3
Unknown symbol __floatsisf
Unknown symbol __mulsf3
Unknown symbol __gesf2
Unknown symbol __addsf3

However, I don't know what those symbols are :( I am a bit worried that 
maybe I've done something that is not supported by the kernel, like 
left-shift 16 bits of an int, or floating operations.

Any hints?

Thanks a lot!
Lei

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-23 14:39               ` Lei Yang
@ 2004-08-23 14:52                 ` Richard B. Johnson
  2004-08-23 15:04                   ` Lei Yang
  2004-08-23 14:52                 ` Alan Cox
  1 sibling, 1 reply; 21+ messages in thread
From: Richard B. Johnson @ 2004-08-23 14:52 UTC (permalink / raw)
  To: Lei Yang
  Cc: Lee Revell, Sam Ravnborg, Kernel Newbies Mailing List,
	linux-kernel

On Mon, 23 Aug 2004, Lei Yang wrote:

> Richard B. Johnson wrote:
>
> > Do `depmod -e test.ko` to see what it's complaining about. You
> > can see all the symbols by using `nm`. Try it. Your code
> > probably didn't define the necessary stuff to make a module.
> > You need to look at a typical module (driver) that comes with the
> > kernel. Just find one of the shortest ".c" files in the driver
> > tree.
>
> Thanks! I did less /var/log/messages, and got the unknown symbols
> Unknown symbol __divsf3
> Unknown symbol __fixsfsi
> Unknown symbol __subsf3
> Unknown symbol __floatsisf
> Unknown symbol __mulsf3
> Unknown symbol __gesf2
> Unknown symbol __addsf3
>
> However, I don't know what those symbols are :( I am a bit worried that
> maybe I've done something that is not supported by the kernel, like
> left-shift 16 bits of an int, or floating operations.
>
> Any hints?
>
> Thanks a lot!
> Lei

You cannot use floating-point in the kernel. It appears that you
are trying to make user-mode code execute within the kernel. It
can't. That's not what a module does. The kernel executes code
on behalf of the user-mode caller, in the context of the caller.
It does things, on behalf of the user, that the user can't
be trusted to do properly by himself. That's all the kernel
is for! Any calculations and similar stuff can be done in
regular user-mode code.

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



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-23 14:39               ` Lei Yang
  2004-08-23 14:52                 ` Richard B. Johnson
@ 2004-08-23 14:52                 ` Alan Cox
  1 sibling, 0 replies; 21+ messages in thread
From: Alan Cox @ 2004-08-23 14:52 UTC (permalink / raw)
  To: Lei Yang
  Cc: root, Lee Revell, Sam Ravnborg, Kernel Newbies Mailing List,
	Linux Kernel Mailing List

On Llu, 2004-08-23 at 15:39, Lei Yang wrote:
> Thanks! I did less /var/log/messages, and got the unknown symbols
> Unknown symbol __divsf3
> Unknown symbol __fixsfsi
> Unknown symbol __subsf3
> Unknown symbol __floatsisf
> Unknown symbol __mulsf3
> Unknown symbol __gesf2
> Unknown symbol __addsf3
> 
> However, I don't know what those symbols are :( I am a bit worried that 
> maybe I've done something that is not supported by the kernel, like 
> left-shift 16 bits of an int, or floating operations.

You are correct - the kernel doesn't support floating point operations
used in kernel space unless you do some fairly tricky stuff.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-23 14:52                 ` Richard B. Johnson
@ 2004-08-23 15:04                   ` Lei Yang
  2004-08-23 15:20                     ` Richard B. Johnson
  2004-08-23 15:25                     ` Sam Ravnborg
  0 siblings, 2 replies; 21+ messages in thread
From: Lei Yang @ 2004-08-23 15:04 UTC (permalink / raw)
  To: root; +Cc: Lee Revell, Sam Ravnborg, Kernel Newbies Mailing List,
	linux-kernel

Richard B. Johnson wrote:
> On Mon, 23 Aug 2004, Lei Yang wrote:
> 
> 
>>Richard B. Johnson wrote:
>>
>>
>>>Do `depmod -e test.ko` to see what it's complaining about. You
>>>can see all the symbols by using `nm`. Try it. Your code
>>>probably didn't define the necessary stuff to make a module.
>>>You need to look at a typical module (driver) that comes with the
>>>kernel. Just find one of the shortest ".c" files in the driver
>>>tree.
>>
>>Thanks! I did less /var/log/messages, and got the unknown symbols
>>Unknown symbol __divsf3
>>Unknown symbol __fixsfsi
>>Unknown symbol __subsf3
>>Unknown symbol __floatsisf
>>Unknown symbol __mulsf3
>>Unknown symbol __gesf2
>>Unknown symbol __addsf3
>>
>>However, I don't know what those symbols are :( I am a bit worried that
>>maybe I've done something that is not supported by the kernel, like
>>left-shift 16 bits of an int, or floating operations.
>>
>>Any hints?
>>
>>Thanks a lot!
>>Lei
> 
> 
> You cannot use floating-point in the kernel. It appears that you
> are trying to make user-mode code execute within the kernel. It
> can't. That's not what a module does. The kernel executes code
> on behalf of the user-mode caller, in the context of the caller.
> It does things, on behalf of the user, that the user can't
> be trusted to do properly by himself. That's all the kernel
> is for! Any calculations and similar stuff can be done in
> regular user-mode code.

Sort of, I am trying to make a usr mode library work with kernel. 
However, floating point operation is necessary in the algorithm. You 
mean that this can never be done? Is changing floating-point the only 
thing I can do now?

Thanks!
Lei

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-23 15:04                   ` Lei Yang
@ 2004-08-23 15:20                     ` Richard B. Johnson
  2004-08-23 15:25                     ` Sam Ravnborg
  1 sibling, 0 replies; 21+ messages in thread
From: Richard B. Johnson @ 2004-08-23 15:20 UTC (permalink / raw)
  To: Lei Yang
  Cc: Lee Revell, Sam Ravnborg, Kernel Newbies Mailing List,
	linux-kernel

On Mon, 23 Aug 2004, Lei Yang wrote:

> Richard B. Johnson wrote:
> > On Mon, 23 Aug 2004, Lei Yang wrote:
> >
> >
> >>Richard B. Johnson wrote:
> >>
> >>
> >>>Do `depmod -e test.ko` to see what it's complaining about. You
> >>>can see all the symbols by using `nm`. Try it. Your code
> >>>probably didn't define the necessary stuff to make a module.
> >>>You need to look at a typical module (driver) that comes with the
> >>>kernel. Just find one of the shortest ".c" files in the driver
> >>>tree.
> >>
> >>Thanks! I did less /var/log/messages, and got the unknown symbols
> >>Unknown symbol __divsf3
> >>Unknown symbol __fixsfsi
> >>Unknown symbol __subsf3
> >>Unknown symbol __floatsisf
> >>Unknown symbol __mulsf3
> >>Unknown symbol __gesf2
> >>Unknown symbol __addsf3
> >>
> >>However, I don't know what those symbols are :( I am a bit worried that
> >>maybe I've done something that is not supported by the kernel, like
> >>left-shift 16 bits of an int, or floating operations.
> >>
> >>Any hints?
> >>
> >>Thanks a lot!
> >>Lei
> >
> >
> > You cannot use floating-point in the kernel. It appears that you
> > are trying to make user-mode code execute within the kernel. It
> > can't. That's not what a module does. The kernel executes code
> > on behalf of the user-mode caller, in the context of the caller.
> > It does things, on behalf of the user, that the user can't
> > be trusted to do properly by himself. That's all the kernel
> > is for! Any calculations and similar stuff can be done in
> > regular user-mode code.
>
> Sort of, I am trying to make a usr mode library work with kernel.
> However, floating point operation is necessary in the algorithm. You
> mean that this can never be done? Is changing floating-point the only
> thing I can do now?
>
> Thanks!
> Lei

Let's put it this way. If you think you need to use a floating-point
library inside the kernel, then you don't understand what the kernel
does or what it was designed to do. You should make a module that
reads from, or writes to, the special hardware you are using. Then,
using user mode code (called a daemon), you read from the device,
perform the floating-point processing, then write to the device.
That way, you are using the kernel priviliges only for reading/writing
to the device.

It is possible to execute floating point code within the kernel
if the context of the floating-point unit is saved first, and
restored after the operation. However, you will never get a
math library to work inside the kernel unless you write your
own. You cannot use the 'C' runtime library inside the kernel.
That library was designed to be outside the kernel (it uses
the kernel).


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

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



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-23 15:04                   ` Lei Yang
  2004-08-23 15:20                     ` Richard B. Johnson
@ 2004-08-23 15:25                     ` Sam Ravnborg
  2004-08-23 15:44                       ` Lei Yang
  1 sibling, 1 reply; 21+ messages in thread
From: Sam Ravnborg @ 2004-08-23 15:25 UTC (permalink / raw)
  To: Lei Yang
  Cc: root, Lee Revell, Sam Ravnborg, Kernel Newbies Mailing List,
	linux-kernel

On Mon, Aug 23, 2004 at 11:04:28AM -0400, Lei Yang wrote:
> 
> Sort of, I am trying to make a usr mode library work with kernel. 
> However, floating point operation is necessary in the algorithm. You 
> mean that this can never be done? Is changing floating-point the only 
> thing I can do now?

Before helping out more with your compile issue please explain in propser
detail what you try to achive.
Reading the above I get the impression you thing a library will run
faster when running in kernel context - and thats what you try to do.

If this is your plan then the answer is: Drop it.

	Sam

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-23 15:25                     ` Sam Ravnborg
@ 2004-08-23 15:44                       ` Lei Yang
  2004-08-23 16:21                         ` Alan Cox
  0 siblings, 1 reply; 21+ messages in thread
From: Lei Yang @ 2004-08-23 15:44 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: root, Kernel Newbies Mailing List, linux-kernel

Sam Ravnborg wrote:
> On Mon, Aug 23, 2004 at 11:04:28AM -0400, Lei Yang wrote:
> 
>>Sort of, I am trying to make a usr mode library work with kernel. 
>>However, floating point operation is necessary in the algorithm. You 
>>mean that this can never be done? Is changing floating-point the only 
>>thing I can do now?
> 
> 
> Before helping out more with your compile issue please explain in propser
> detail what you try to achive.
> Reading the above I get the impression you thing a library will run
> faster when running in kernel context - and thats what you try to do.
> 
> If this is your plan then the answer is: Drop it.


NO, this is not my plan :)

I was trying to build a compression/decompression utility with my 
algorithm in kernel, and want to use it in some of the device drivers.
And in that algorithm, we need floating-point.

Thanks!
Lei

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-23 14:29             ` Richard B. Johnson
  2004-08-23 14:39               ` Lei Yang
@ 2004-08-23 15:48               ` Andreas Schwab
  1 sibling, 0 replies; 21+ messages in thread
From: Andreas Schwab @ 2004-08-23 15:48 UTC (permalink / raw)
  To: root
  Cc: Lei Yang, Lee Revell, Sam Ravnborg, Kernel Newbies Mailing List,
	linux-kernel

"Richard B. Johnson" <root@chaos.analogic.com> writes:

> A function looks like this:
>
> int present()
> {
>
> }
>
> A prototype for the same function looks like this:
>
> int present(void);
>
> Functions always have "{}". Prototypes never do.

A function definition is also a prototype unless you use oldstyle
definitions.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Problems compiling kernel modules
  2004-08-23 15:44                       ` Lei Yang
@ 2004-08-23 16:21                         ` Alan Cox
  0 siblings, 0 replies; 21+ messages in thread
From: Alan Cox @ 2004-08-23 16:21 UTC (permalink / raw)
  To: Lei Yang
  Cc: Sam Ravnborg, root, Kernel Newbies Mailing List,
	Linux Kernel Mailing List

On Llu, 2004-08-23 at 16:44, Lei Yang wrote:
> I was trying to build a compression/decompression utility with my 
> algorithm in kernel, and want to use it in some of the device drivers.
> And in that algorithm, we need floating-point.

In which case the best place to look (if it needs to be kernel side) is
probably drivers/md/ which shows how you can use the FPU state. There is
a cost to it as you have to save/restore the user FP state and on x86
that is expensive of course.

Historically we've always tried to keep compression algorithms in user
space. The video4linux layer for example pushes most of this to the user
and that allows the user program to make a more intelligent assessment
of the input format and desired target. This avoids things like kernel
drivers turning data from one format to another and user space libraries
turning it back again.

Alan


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2004-08-23 17:26 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-21 19:24 Problems compiling kernel modules Lei Yang
2004-08-21 21:44 ` Sam Ravnborg
2004-08-21 19:45   ` Lei Yang
2004-08-21 20:05     ` viro
2004-08-21 20:13     ` Lee Revell
2004-08-21 21:50     ` Sam Ravnborg
2004-08-21 19:55       ` Lei Yang
2004-08-21 20:46       ` Lei Yang
2004-08-21 20:57         ` Lee Revell
2004-08-23 14:10           ` Lei Yang
2004-08-23 14:29             ` Richard B. Johnson
2004-08-23 14:39               ` Lei Yang
2004-08-23 14:52                 ` Richard B. Johnson
2004-08-23 15:04                   ` Lei Yang
2004-08-23 15:20                     ` Richard B. Johnson
2004-08-23 15:25                     ` Sam Ravnborg
2004-08-23 15:44                       ` Lei Yang
2004-08-23 16:21                         ` Alan Cox
2004-08-23 14:52                 ` Alan Cox
2004-08-23 15:48               ` Andreas Schwab
2004-08-21 21:11         ` Alex Goddard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox