VirtualBox

Changeset 89047 in vbox for trunk/include


Ignore:
Timestamp:
May 14, 2021 1:51:39 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144387
Message:

iprt: Linux: introduce Ubuntu kernel version checker macros, ​bugref:10007.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/linux/version.h

    r88978 r89047  
    3232
    3333#include <linux/version.h>
     34
     35/* We need utsrelease.h in order to detect Ubuntu kernel,
     36 * i.e. check if UTS_UBUNTU_RELEASE_ABI is defined. Support kernels
     37 * starting from Ubuntu 14.04 Trusty which is based on upstream
     38 * kernel 3.13.x. */
     39#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
     40# include <generated/utsrelease.h>
     41# include <iprt/cdefs.h>
     42#endif
    3443
    3544/** @def RTLNX_VER_MIN
     
    116125
    117126
     127#if defined(UTS_UBUNTU_RELEASE_ABI)
     128/* Ubuntu kernel ABI version is represented as a constant which can be interpreted
     129 * by compiler as an octal constant (e.g. 050818). We add '0x' prefix to it in
     130 * order to be able to treat it as a hexadecimal number. */
     131# define RTLNX_UBUNTU_ABI(a_iAbi)   (RT_CONCAT(0x,a_iAbi))
     132
     133/** @def RTLNX_UBUNTU_ABI_MIN
     134 * Require Ubuntu release to be equal or newer than specified version.
     135 * Kernel version should exactly match to specified @a_iMajor, @a_iMinor
     136 * and @a_iPatch. Number @a_iAbi should be equal or greater than current
     137 * ABI version.
     138 *
     139 * @param a_iMajor      The major kernel version number.
     140 * @param a_iMinor      The minor kernel version number.
     141 * @param a_iPatch      The micro kernel version number.
     142 * @param a_iAbi        Ubuntu kernel ABI version number.
     143 */
     144# define RTLNX_UBUNTU_ABI_MIN(a_iMajor, a_iMinor, a_iPatch, a_iAbi) \
     145    (   KERNEL_VERSION(a_iMajor, a_iMinor, a_iPatch) == LINUX_VERSION_CODE \
     146     && RTLNX_UBUNTU_ABI(UTS_UBUNTU_RELEASE_ABI) >= RTLNX_UBUNTU_ABI(a_iAbi))
     147
     148/** @def RTLNX_UBUNTU_ABI_MAX
     149 * Require Ubuntu release to be older than specified version.
     150 * Kernel version should exactly match to specified @a_iMajor, @a_iMinor
     151 * and @a_iPatch. Number @a_iAbi should be less than current ABI version.
     152 *
     153 * @param a_iMajor      The major kernel version number.
     154 * @param a_iMinor      The minor kernel version number.
     155 * @param a_iPatch      The micro kernel version number.
     156 * @param a_iAbi        Ubuntu kernel ABI version number.
     157 */
     158# define RTLNX_UBUNTU_ABI_MAX(a_iMajor, a_iMinor, a_iPatch, a_iAbi) \
     159    (   KERNEL_VERSION(a_iMajor, a_iMinor, a_iPatch) == LINUX_VERSION_CODE \
     160     && RTLNX_UBUNTU_ABI(UTS_UBUNTU_RELEASE_ABI) < RTLNX_UBUNTU_ABI(a_iAbi))
     161
     162/** @def RTLNX_UBUNTU_RANGE
     163 * Require Ubuntu release to be in specified ABI versions range.
     164 * Kernel version should exactly match to specified @a_iMajor, @a_iMinor
     165 * and @a_iPatch. Numbers @a_iAbiMin and @a_iAbiMax specify ABI versions range.
     166 * The max version is exclusive, the minimum inclusive.
     167 *
     168 * @param a_iMajor      The major kernel version number.
     169 * @param a_iMinor      The minor kernel version number.
     170 * @param a_iPatch      The micro kernel version number.
     171 * @param a_iAbiMin     Ubuntu kernel ABI version number (minimum).
     172 * @param a_iAbiMax     Ubuntu kernel ABI version number (maximum).
     173 */
     174# define RTLNX_UBUNTU_ABI_RANGE(a_iMajor, a_iMinor, a_iPatch, a_iAbiMin, a_iAbiMax) \
     175    (   RTLNX_UBUNTU_ABI_MIN(a_iMajor, a_iMinor, a_iPatch, a_iAbiMin) \
     176     && RTLNX_UBUNTU_ABI_MAX(a_iMajor, a_iMinor, a_iPatch, a_iAbiMax))
     177
     178#else /* !UTS_UBUNTU_RELEASE_ABI */
     179
     180# define RTLNX_UBUNTU_ABI_MIN(a_iMajor, a_iMinor, a_iPatch, a_iAbi) (0)
     181# define RTLNX_UBUNTU_ABI_MAX(a_iMajor, a_iMinor, a_iPatch, a_iAbi) (0)
     182# define RTLNX_UBUNTU_ABI_RANGE(a_iMajorMin, a_iMinorMin, a_iPatchMin, a_iAbiMin, \
     183    a_iMajorMax, a_iMinorMax, a_iPatchMax, a_iAbiMax) (0)
     184
     185#endif /* !UTS_UBUNTU_RELEASE_ABI */
     186
    118187#endif /* !IPRT_INCLUDED_linux_version_h */
    119188
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette