|
Driver porting: hello worldDriver porting: hello worldPosted Aug 13, 2007 0:23 UTC (Mon) by apc20 (guest, #46735)Parent article: Driver porting: hello world
Does anyone know how to link in the C math libraries (math.h)? I've had no luck getting a device driver to compile by linking in math.h ( -lm in the old Makefile).
Thanks,
Alex
(Log in to post comments)
Driver porting: hello world Posted Aug 13, 2007 16:31 UTC (Mon) by zlynx (subscriber, #2285) [Link] The kernel does not have the Standard C libraries. It's a free-standing program, like some embedded code. The only libraries you are allowed to use are the ones declared in the Linux source include directories.
Math libraries are generally for floating point. The Linux kernel does not support floating point inside the kernel. Floating point adds a rather large and slow set of registers to save and restore. Not doing the save/restore means context switch in and out of the kernel is much faster.
You *can* do floating point in kernel if you *really* want to, but you'd better know exactly what you're doing. If your calculations are not precison critical, it'd be faster to use fractional integer math and small lookup tables to estimate things like sqrt and trig functions.
|
Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.