#ifndef MODINFO_H_
#define MODINFO_H_

#define _QUOTE(s) #s
#define QUOTE(s) _QUOTE(s)

#define _CAT(a, b) a ## b
#define CAT(a, b) _CAT(a, b)

// Insert a Key/value pair in the ".modinfo" section of the ELF executable which
// can be extracted using modinfo; a standard tool shipped with the Linux kernel.
// Both parameters are expected to be strings.
#define MODINFO(tag, info)                                                      \
static const char CAT(key, __LINE__)[]                                          \
    __attribute__((section(".modinfo")))  /* Put in the modinfo section.   */   \
    __attribute__((__used__))             /* Emit even if not referenced.  */   \
    __attribute__((unused))               /* Don't warn if not referenced. */   \
    __attribute__((aligned(1)))           /* Byte aligned, i.e. no padding.*/   \
    = tag "=\t" info

#endif /* MODINFO_H_ */