Over the years, we tend to collect little snippets of code and routines that we use, like, refine and reuse.
I’ve done so, for (mostly) user-space and kernel programming on the 2.6 / 3.x Linux kernel. Feel free to use it. Please do get back with any bugs you find, suggestions, etc.
License: GPL / LGPL
There are macros / functions to:
- make debug prints along with function name and line# info (via the usual printk() or trace_printk()) – (only if DEBUG mode is On)
- will preferably use rate-limited printk’s
- dump the kernel-mode stack
- print the current context (process or interrupt along with flags in the form that ftrace uses)
- a simple assert() macro (!)
- a cpu-intensive DELAY_LOOP (useful for test rigs that must spin on the processor)
- an equivalent to usermode sleep functionality
- a function to calculate the time delta given two timestamps (timeval structs)
- convert decimal to binary, and
- a few more.