The attached patch adds a set of scaled math routines to the system. The code is completly contained in a header file and all the functions are inline asm. A generic version is provide for archs other than i386. The generic should do all that is needed for 64-bit machines, but 32-bit machines should have asm version for efficiency. No code will be generated until some one submits a following patch that uses these functions. The cpu frequency folks have expressed an interest in using these functions do do the frequency change math. (the following are excerpts from the Documentation file included in the patch) What is scaled math? Scaled math is a method of doing integer math which allows you to: A.) Work with fractions in integer math. B.) Use MPY instead of DIV (much faster). C.) To reduce round off (or digitizing) errors. Basically, in scaled math you would replace an equation of this sort: r = foo / bar or r = foo * top / bar with this: r = (foo * SC) / (bar * SC) or r = (foo * top *SC) / (bar * SC) Regrouping these: r = foo * (SC / bar) / SC or r = foo * ((top * SC) / bar) / SC SC is the scale factor. We choose SC carefully to retain the most bits in the calculation and to make the math easy. We make the math easy by making SC be a power of 2 so the * SC and / SC operations are just shifts. Notes on the sc_math.h functions: What the sc_math.h functions do is to provide routines that allow usage of the ability of the hardware to multiply two integers and return a result that is twice the length of the original integers. At the same time it provides access to the divide instruction which can divide a 64-bit numerator by a 32-bit denominator and return a 32-bit quotient and remainder. In addition, to help with the scaling, routines are provide that combine the common scaling shift operation with the multiply or divide. Since (2**32) is a common scaling, functions to deal with it most efficiently are provided. Functions that allow easy calculation of conversion constants at compile time are also provided. -- George Anzinger george@mvista.com High-res-timers: http://sourceforge.net/projects/high-res-timers/ Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml