Not logged in
Log in now
Create an account
Subscribe to LWN
LWN.net Weekly Edition for May 16, 2013
A look at the PyPy 2.0 release
PostgreSQL 9.3 beta: Federated databases and more
LWN.net Weekly Edition for May 9, 2013
(Nearly) full tickless operation in 3.10
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).
Driver porting: hello world
Posted Aug 13, 2007 16:31 UTC (Mon) by zlynx (subscriber, #2285)
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 © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds