Skip to content

Instantly share code, notes, and snippets.

@stefano-garzarella
Last active January 22, 2016 11:27
Show Gist options
  • Save stefano-garzarella/c35c9f7263dbb8d19f11 to your computer and use it in GitHub Desktop.
Save stefano-garzarella/c35c9f7263dbb8d19f11 to your computer and use it in GitHub Desktop.
Linux kprintf with some debug info
#define _dprintk(_fmt, ... )\
do { \
struct timeval _t0; \
do_gettimeofday(&_t0); \
printk(KERN_ERR "%03d.%06d %s():%d - " _fmt "%s\n", \
(int)(_t0.tv_sec % 1000), (int)_t0.tv_usec, \
__func__, __LINE__, __VA_ARGS__); \
} while (0);
#define sprintk(...) _dprintk(__VA_ARGS__, "")
#ifdef PDEBUG
#define dprintk(...) _dprintk(__VA_ARGS__, "")
#else
#define dprintk(...) do {} while(0);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment