clinuxlinux-kernelpredefined-variablespredefined-macro

What is __VMKLNX__ in Linux header files?


In a lot of Linux kernel modules (hardware drivers) their source header files, one can spot lines like:

#ifndef __VMKLNX__

__VMKLNX__ is not defined in the source code of this module. A guess is that __VMKLNX__ is a "C" system specific predefined macro. Maybe related to virtual machines or even VMware. However I can't find any authoritative source to confirm this.

What is and how/where can I find the meaning of this __VMKLNX__ part?


Solution

  • That means the driver supports being built for the VMware ESX kernel, whose documentation and source code are not public. The VMware ESX kernel is a hypervisor commonly called "vmkernel". You can infer what __VMKLNX__ is for by looking at code comments in existing drivers, like in bnx2.c:

    #if defined(__VMKLNX__)
    /* On VMware ESX there is a possibility that that netdev watchdog thread
     * runs before the reset task if the machine is loaded.  If this occurs
     * too many times, these premature watchdog triggers will cause a PSOD
     * on a VMware ESX beta build */ 
    #define TX_TIMEOUT  (20*HZ)
    #else
    #define TX_TIMEOUT  (5*HZ)
    #endif /* defined(__VMKLNX__) */
    

    VMware ESX isn't linux, though. The ESX kernel just implements an interface that allows it to run Linux device drivers.