VirtualBox

Changeset 85698 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 11, 2020 5:05:29 PM (4 years ago)
Author:
vboxsync
Message:

IPRT,lnx-kmods: Use new linux kernel version checking macros. Moved them to separate wrapper header.

Location:
trunk/src/VBox
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c

    r82968 r85698  
    3636#include "the-linux-kernel.h"
    3737
    38 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
     38#if RTLNX_VER_MIN(2,6,15)
    3939# define VBOXGUEST_WITH_INPUT_DRIVER
    4040#endif
    4141
    42 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
     42#if RTLNX_VER_MIN(4,15,0)
    4343# define CONST_4_15 const
    4444#else
     
    5252#include <linux/miscdevice.h>
    5353#include <linux/poll.h>
    54 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     54#if RTLNX_VER_MIN(2,6,28)
    5555# include <linux/tty.h>
    5656#endif
     
    9090
    9191/* uidgid.h was introduced in 3.5.0. */
    92 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0)
     92#if RTLNX_VER_MAX(3,5,0)
    9393# define kgid_t gid_t
    9494# define kuid_t uid_t
     
    142142static VMMDevReqMouseStatus    *g_pMouseStatusReq;
    143143#endif
    144 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     144#if RTLNX_VER_MIN(2,6,0)
    145145/** Whether we've create the logger or not. */
    146146static volatile bool            g_fLoggerCreated;
     
    364364 * @param   pRegs           Register set. Removed in 2.6.19.
    365365 */
    366 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && !defined(DOXYGEN_RUNNING)
     366#if RTLNX_VER_MIN(2,6,19) && !defined(DOXYGEN_RUNNING)
    367367static irqreturn_t vgdrvLinuxISR(int iIrq, void *pvDevId)
    368368#else
     
    385385    rc = request_irq(g_pPciDev->irq,
    386386                     vgdrvLinuxISR,
    387 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     387#if RTLNX_VER_MIN(2,6,20)
    388388                     IRQF_SHARED,
    389389#else
     
    477477            g_pInputDevice->open       = vboxguestOpenInputDevice;
    478478            g_pInputDevice->close      = vboxguestCloseInputDevice;
    479 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
     479# if RTLNX_VER_MAX(2,6,22)
    480480            g_pInputDevice->cdev.dev   = &g_pPciDev->dev;
    481481# else
     
    596596    if (RT_SUCCESS(rc))
    597597    {
    598 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     598#if RTLNX_VER_MIN(2,6,0)
    599599        RTLogGroupSettings(pRelLogger, g_szLogGrp);
    600600        RTLogFlags(pRelLogger, g_szLogFlags);
     
    603603        RTLogRelSetDefaultInstance(pRelLogger);
    604604    }
    605 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     605#if RTLNX_VER_MIN(2,6,0)
    606606    g_fLoggerCreated = true;
    607607#endif
     
    616616         * Call the common device extension initializer.
    617617         */
    618 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) && defined(RT_ARCH_X86)
     618#if RTLNX_VER_MIN(2,6,0) && defined(RT_ARCH_X86)
    619619        VBOXOSTYPE enmOSType = VBOXOSTYPE_Linux26;
    620 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) && defined(RT_ARCH_AMD64)
     620#elif RTLNX_VER_MIN(2,6,0) && defined(RT_ARCH_AMD64)
    621621        VBOXOSTYPE enmOSType = VBOXOSTYPE_Linux26_x64;
    622 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0) && defined(RT_ARCH_X86)
     622#elif RTLNX_VER_MIN(2,4,0) && defined(RT_ARCH_X86)
    623623        VBOXOSTYPE enmOSType = VBOXOSTYPE_Linux24;
    624 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0) && defined(RT_ARCH_AMD64)
     624#elif RTLNX_VER_MIN(2,4,0) && defined(RT_ARCH_AMD64)
    625625        VBOXOSTYPE enmOSType = VBOXOSTYPE_Linux24_x64;
    626626#else
     
    740740DECLINLINE(RTUID) vgdrvLinuxGetUid(void)
    741741{
    742 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
    743 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     742#if RTLNX_VER_MIN(2,6,29)
     743# if RTLNX_VER_MIN(3,5,0)
    744744    return from_kuid(current_user_ns(), current->cred->uid);
    745745# else
     
    760760DECLINLINE(bool) vgdrvLinuxIsGroupZero(kgid_t gid)
    761761{
    762 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     762#if RTLNX_VER_MIN(3,5,0)
    763763    return from_kgid(current_user_ns(), gid);
    764764#else
     
    793793    uint32_t           fRet = VMMDEV_REQUESTOR_CON_DONT_KNOW;
    794794
    795 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) /* First with tty_kref_put(). */
     795#if RTLNX_VER_MIN(2,6,28) /* First with tty_kref_put(). */
    796796    /*
    797797     * Check for tty0..63, ASSUMING that these are only used for the physical console.
     
    800800    if (pTty)
    801801    {
    802 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
     802# if RTLNX_VER_MIN(4,2,0)
    803803        const char *pszName = tty_name(pTty);
    804804# else
     
    879879         pFilp, pFilp->private_data, RTProcSelf(), current->pid, current->comm));
    880880
    881 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)
     881#if RTLNX_VER_MAX(2,6,28)
    882882    /* This housekeeping was needed in older kernel versions to ensure that
    883883     * the file pointer didn't get left on the polling queue. */
     
    11881188
    11891189
    1190 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     1190#if RTLNX_VER_MIN(2,6,0)
    11911191
    11921192/** log and dbg_log parameter setter. */
  • trunk/src/VBox/Additions/common/VBoxGuest/linux/files_vboxguest

    r83917 r85698  
    7070    ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \
    7171    ${PATH_ROOT}/include/iprt/x86.h=>include/iprt/x86.h \
     72    ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \
    7273    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
    7374    ${PATH_ROOT}/include/VBox/err.h=>include/VBox/err.h \
  • trunk/src/VBox/Additions/linux/sharedfolders/dirops.c

    r82968 r85698  
    3636#include <iprt/err.h>
    3737
    38 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
     38#if RTLNX_VER_MAX(4,7,0)
    3939# define d_in_lookup(a_pDirEntry)  (d_unhashed(a_pDirEntry))
    4040#endif
     
    280280 */
    281281DECL_NO_INLINE(static, bool) vbsf_dir_emit_nls(
    282 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
     282# if RTLNX_VER_MIN(3,11,0)
    283283                                               struct dir_context *ctx,
    284284# else
     
    291291    int rc = vbsf_nlscpy(pSuperInfo, szDstName, sizeof(szDstName), pszSrcName, cchSrcName);
    292292    if (rc == 0) {
    293 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
     293#if RTLNX_VER_MIN(3,11,0)
    294294        return dir_emit(ctx, szDstName, strlen(szDstName), d_ino, d_type);
    295295#else
     
    327327 * c. filldir returns an error (see comment on that)
    328328 */
    329 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
     329#if RTLNX_VER_MIN(3,11,0)
    330330static int vbsf_dir_iterate(struct file *dir, struct dir_context *ctx)
    331331#else
     
    333333#endif
    334334{
    335 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
     335#if RTLNX_VER_MIN(3,11,0)
    336336    loff_t                  offPos = ctx->pos;
    337337#else
     
    403403     */
    404404    if (offPos < 2) {
    405 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
     405#if RTLNX_VER_MIN(3,11,0)
    406406        if (offPos == 0) {
    407407            if (dir_emit_dot(dir, ctx))
     
    431431        }
    432432        if (offPos == 1) {
    433 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 5)
     433# if RTLNX_VER_MIN(2,5,5)
    434434            rc = filldir(opaque, "..", 2, 1, parent_ino(VBSF_GET_F_DENTRY(dir)), DT_DIR);
    435435# else
     
    506506                bool        fContinue;
    507507                if (pSuperInfo->fNlsIsUtf8) {
    508 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
     508#if RTLNX_VER_MIN(3,11,0)
    509509                    fContinue = dir_emit(ctx, pEntry->name.String.ach, cchSrcName, d_ino, d_type);
    510510#else
     
    512512#endif
    513513                } else {
    514 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
     514#if RTLNX_VER_MIN(3,11,0)
    515515                    fContinue = vbsf_dir_emit_nls(ctx, pEntry->name.String.ach, cchSrcName, d_ino, d_type, pSuperInfo);
    516516#else
     
    536536            offPos       += 1;
    537537            dir->f_pos    = offPos;
    538 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
     538#if RTLNX_VER_MIN(3,11,0)
    539539            ctx->pos      = offPos;
    540540#endif
     
    555555struct file_operations vbsf_dir_fops = {
    556556    .open           = vbsf_dir_open,
    557 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
     557#if RTLNX_VER_MIN(4,7,0)
    558558    .iterate_shared = vbsf_dir_iterate,
    559 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
     559#elif RTLNX_VER_MIN(3,11,0)
    560560    .iterate        = vbsf_dir_iterate,
    561561#else
     
    564564    .release        = vbsf_dir_release,
    565565    .read           = generic_read_dir,
    566 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
     566#if RTLNX_VER_MIN(2,6,37)
    567567    .llseek         = generic_file_llseek
    568568#endif
     
    588588    if (sf_new_i) {
    589589        ino_t         iNodeNo = iunique(parent->i_sb, 16);
    590 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)
     590#if RTLNX_VER_MIN(2,4,25)
    591591        struct inode *pInode  = iget_locked(parent->i_sb, iNodeNo);
    592592#else
     
    614614            if (fInstantiate)
    615615                d_instantiate(dentry, pInode);
    616 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)
     616#if RTLNX_VER_MIN(2,4,25)
    617617            unlock_new_inode(pInode);
    618618#endif
     
    632632DECLINLINE(void) vbsf_d_add_inode(struct dentry *dentry, struct inode *pNewInode)
    633633{
    634 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
     634#if RTLNX_VER_MIN(2,6,38)
    635635    Assert(dentry->d_op == &vbsf_dentry_ops); /* (taken from the superblock) */
    636636#else
     
    651651 */
    652652static struct dentry *vbsf_inode_lookup(struct inode *parent, struct dentry *dentry
    653 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
     653#if RTLNX_VER_MIN(3,6,0)
    654654                                        , unsigned int flags
    655 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     655#elif RTLNX_VER_MIN(2,6,0)
    656656                                        , struct nameidata *nd
    657657#endif
     
    664664    int                     rc;
    665665
    666 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
     666#if RTLNX_VER_MIN(3,6,0)
    667667    SFLOGFLOW(("vbsf_inode_lookup: parent=%p dentry=%p flags=%#x\n", parent, dentry, flags));
    668 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     668#elif RTLNX_VER_MIN(2,6,0)
    669669    SFLOGFLOW(("vbsf_inode_lookup: parent=%p dentry=%p nd=%p{.flags=%#x}\n", parent, dentry, nd, nd ? nd->flags : 0));
    670670#else
     
    920920
    921921
    922 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     922#if RTLNX_VER_MIN(3,16,0)
    923923/**
    924924 * More atomic way of handling creation.
     
    930930static int vbsf_inode_atomic_open(struct inode *pDirInode, struct dentry *dentry, struct file *file,  unsigned fOpen,
    931931                                  umode_t fMode
    932 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0)
     932# if RTLNX_VER_MAX(4,19,0)
    933933                                  , int *opened
    934934# endif
     
    982982                 * and call finish_open() to do the remaining open() work.
    983983                 */
    984 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
     984# if RTLNX_VER_MIN(4,19,0)
    985985                if (fCreated)
    986986                    file->f_mode |= FMODE_CREATED;
     
    10451045 * @returns 0 on success, Linux error code otherwise
    10461046 */
    1047 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) || defined(DOXYGEN_RUNNING)
     1047#if RTLNX_VER_MIN(3,6,0) || defined(DOXYGEN_RUNNING)
    10481048static int vbsf_inode_create(struct inode *parent, struct dentry *dentry, umode_t mode, bool excl)
    1049 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
     1049#elif RTLNX_VER_MIN(3,3,0)
    10501050static int vbsf_inode_create(struct inode *parent, struct dentry *dentry, umode_t mode, struct nameidata *nd)
    1051 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 75)
     1051#elif RTLNX_VER_MIN(2,5,75)
    10521052static int vbsf_inode_create(struct inode *parent, struct dentry *dentry, int mode, struct nameidata *nd)
    10531053#else
     
    10581058                          | SHFL_CF_ACT_FAIL_IF_EXISTS
    10591059                          | SHFL_CF_ACCESS_READWRITE;
    1060 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 75)
     1060#if RTLNX_VER_RANGE(2,5,75,  3,6,0)
    10611061    /* Clear the RD flag if write-only access requested.  Otherwise assume we
    10621062       need write access to create stuff. */
     
    10821082 * @returns 0 on success, Linux error code otherwise
    10831083 */
    1084 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
     1084#if RTLNX_VER_MIN(3,3,0)
    10851085static int vbsf_inode_mkdir(struct inode *parent, struct dentry *dentry, umode_t mode)
    10861086#else
     
    12031203    uint32_t fRename = (old_dentry->d_inode->i_mode & S_IFDIR ? SHFL_RENAME_DIR : SHFL_RENAME_FILE)
    12041204                     | SHFL_RENAME_REPLACE_IF_EXISTS;
    1205 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)
     1205#if RTLNX_VER_MIN(3,15,0)
    12061206    if (!(flags & ~RENAME_NOREPLACE)) {
    12071207        if (flags & RENAME_NOREPLACE)
     
    12731273            rc = -EXDEV;
    12741274        }
    1275 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)
     1275#if RTLNX_VER_MIN(3,15,0)
    12761276    } else {
    12771277        SFLOGFLOW(("vbsf_inode_rename: Unsupported flags: %#x\n", flags));
     
    12851285
    12861286
    1287 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
     1287#if RTLNX_VER_MAX(4,9,0)
    12881288/**
    12891289 * The traditional rename interface without any flags.
     
    13731373struct inode_operations vbsf_dir_iops = {
    13741374    .lookup         = vbsf_inode_lookup,
    1375 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     1375#if RTLNX_VER_MIN(3,16,0)
    13761376    .atomic_open    = vbsf_inode_atomic_open,
    13771377#endif
     
    13811381    .rmdir          = vbsf_inode_rmdir,
    13821382    .unlink         = vbsf_inode_unlink,
    1383 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
     1383#if RTLNX_VER_MIN(4,9,0)
    13841384    .rename         = vbsf_inode_rename,
    13851385#else
    13861386    .rename         = vbsf_inode_rename_no_flags,
    1387 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)
     1387# if RTLNX_VER_MIN(3,15,0)
    13881388    .rename2        = vbsf_inode_rename,
    13891389# endif
    13901390#endif
    1391 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 18)
     1391#if RTLNX_VER_MIN(2,5,18)
    13921392    .getattr        = vbsf_inode_getattr,
    13931393#else
  • trunk/src/VBox/Additions/linux/sharedfolders/files_vboxsf

    r82968 r85698  
    4545    ${PATH_ROOT}/include/iprt/uni.h=>include/iprt/uni.h \
    4646    ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \
     47    ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \
    4748    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
    4849    ${PATH_ROOT}/include/VBox/err.h=>include/VBox/err.h \
  • trunk/src/VBox/Additions/linux/sharedfolders/lnkops.c

    r82968 r85698  
    108108}
    109109
    110 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
     110#if RTLNX_VER_MIN(4,5,0)
    111111
    112112/**
     
    147147#else /* < 4.5 */
    148148
    149 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 8)
     149# if RTLNX_VER_MAX(2,6,8)
    150150/**
    151151 * Reads the link into the given buffer.
     
    183183 * Follow link in dentry.
    184184 */
    185 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
     185# if RTLNX_VER_MIN(4,2,0)
    186186static const char *vbsf_follow_link(struct dentry *dentry, void **cookie)
    187 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
     187# elif RTLNX_VER_MIN(2,6,13)
    188188static void       *vbsf_follow_link(struct dentry *dentry, struct nameidata *nd)
    189189# else
     
    213213                 */
    214214                vbsf_dentry_chain_increase_ttl(dentry);
    215 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
     215# if RTLNX_VER_MIN(4,2,0)
    216216                *cookie = pszTarget;
    217217                return pszTarget;
    218 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8)
     218# elif RTLNX_VER_MIN(2,6,8)
    219219                nd_set_link(nd, pszTarget);
    220 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
     220#  if RTLNX_VER_MIN(2,6,13)
    221221                return NULL;
    222222#  else
     
    241241        rc = -ENOMEM;
    242242    }
    243 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
     243# if RTLNX_VER_MIN(4,2,0)
    244244    *cookie = ERR_PTR(rc);
    245245    return (const char *)ERR_PTR(rc);
    246 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8)
     246# elif RTLNX_VER_MIN(2,6,8)
    247247    nd_set_link(nd, (char *)ERR_PTR(rc));
    248 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
     248#  if RTLNX_VER_MIN(2,6,13)
    249249    return NULL;
    250250#  else
     
    256256}
    257257
    258 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8)
     258# if RTLNX_VER_MIN(2,6,8)
    259259/**
    260260 * For freeing target link buffer allocated by vbsf_follow_link.
     
    262262 * For kernels before 2.6.8 memory isn't being kept around.
    263263 */
    264 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
     264#  if RTLNX_VER_MIN(4,2,0)
    265265static void vbsf_put_link(struct inode *inode, void *cookie)
    266 #  elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
     266#  elif RTLNX_VER_MIN(2,6,13)
    267267static void vbsf_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
    268268#  else
     
    270270#  endif
    271271{
    272 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
     272#  if RTLNX_VER_MIN(2,6,13)
    273273    char *page = cookie;
    274274#  else
     
    287287 */
    288288struct inode_operations vbsf_lnk_iops = {
    289 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
    290 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8)
     289#if RTLNX_VER_MAX(4,10,0)
     290# if RTLNX_VER_MIN(2,6,8)
    291291    .readlink    = generic_readlink,
    292292# else
     
    294294# endif
    295295#endif
    296 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
     296#if RTLNX_VER_MIN(4,5,0)
    297297    .get_link    = vbsf_get_link
    298298#else
    299299    .follow_link = vbsf_follow_link,
    300 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8)
     300# if RTLNX_VER_MIN(2,6,8)
    301301    .put_link    = vbsf_put_link,
    302302# endif
  • trunk/src/VBox/Additions/linux/sharedfolders/regops.c

    r85693 r85698  
    3535#include "vfsmod.h"
    3636#include <linux/uio.h>
    37 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 32)
     37#if RTLNX_VER_MIN(2,5,32)
    3838# include <linux/aio.h> /* struct kiocb before 4.1 */
    3939#endif
    40 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 12)
     40#if RTLNX_VER_MIN(2,5,12)
    4141# include <linux/buffer_head.h>
    4242#endif
    43 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 12) \
    44  && LINUX_VERSION_CODE <  KERNEL_VERSION(2, 6, 31)
     43#if RTLNX_VER_RANGE(2,5,12,  2,6,31)
    4544# include <linux/writeback.h>
    4645#endif
    47 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23) \
    48  && LINUX_VERSION_CODE <  KERNEL_VERSION(3, 16, 0)
     46#if RTLNX_VER_RANGE(2,6,23,  3,16,0)
    4947# include <linux/splice.h>
    5048#endif
    51 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) \
    52  && LINUX_VERSION_CODE <  KERNEL_VERSION(2, 6, 23)
     49#if RTLNX_VER_RANGE(2,6,17,  2,6,23)
    5350# include <linux/pipe_fs_i.h>
    5451#endif
    55 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 10)
     52#if RTLNX_VER_MIN(2,4,10)
    5653# include <linux/swap.h> /* for mark_page_accessed */
    5754#endif
    5855#include <iprt/err.h>
    5956
    60 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
     57#if RTLNX_VER_MAX(2,6,18)
    6158# define SEEK_END 2
    6259#endif
    6360
    64 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
     61#if RTLNX_VER_MAX(3,16,0)
    6562# define iter_is_iovec(a_pIter) ( !((a_pIter)->type & ITER_KVEC) )
    66 #elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
     63#elif RTLNX_VER_MAX(3,19,0)
    6764# define iter_is_iovec(a_pIter) ( !((a_pIter)->type & (ITER_KVEC | ITER_BVEC)) )
    6865#endif
    6966
    70 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0)
     67#if RTLNX_VER_MAX(4,17,0)
    7168# define vm_fault_t int
    7269#endif
    7370
    74 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 20)
     71#if RTLNX_VER_MAX(2,5,20)
    7572# define pgoff_t    unsigned long
    7673#endif
    7774
    78 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 12)
     75#if RTLNX_VER_MAX(2,5,12)
    7976# define PageUptodate(a_pPage) Page_Uptodate(a_pPage)
    8077#endif
     
    8481*   Structures and Typedefs                                                                                                      *
    8582*********************************************************************************************************************************/
    86 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
     83#if RTLNX_VER_MAX(3,16,0)
    8784struct vbsf_iov_iter {
    8885    unsigned int        type;
     
    107104#endif
    108105
    109 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     106#if RTLNX_VER_MIN(2,6,19)
    110107/** Used by vbsf_iter_lock_pages() to keep the first page of the next segment. */
    111108struct vbsf_iter_stash {
     
    113110    size_t          off;
    114111    size_t          cb;
    115 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
     112# if RTLNX_VER_MAX(4,11,0)
    116113    size_t          offFromEnd;
    117114    struct iov_iter Copy;
     
    120117#endif /* >= 3.16.0 */
    121118/** Initializer for struct vbsf_iter_stash. */
    122 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     119#if RTLNX_VER_MIN(4,11,0)
    123120# define VBSF_ITER_STASH_INITIALIZER    { NULL, 0 }
    124121#else
     
    140137*   Provide more recent uio.h functionality to older kernels.                                                                    *
    141138*********************************************************************************************************************************/
    142 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     139#if RTLNX_VER_RANGE(2,6,19,  3,16,0)
    143140
    144141/**
     
    299296
    300297#endif /* 2.6.19 <= linux < 3.16.0 */
    301 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 35)
     298#if RTLNX_VER_RANGE(3,16,0,  3,16,35)
    302299
    303300/** This is for implementing cMaxPage on 3.16 which doesn't have it. */
     
    319316
    320317#endif /* 3.16.0-3.16.34 */
    321 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
     318#if RTLNX_VER_RANGE(2,6,19,  3,18,0)
    322319
    323320static size_t copy_from_iter(uint8_t *pbDst, size_t cbToCopy, struct iov_iter *pSrcIter)
     
    325322    size_t const cbTotal = cbToCopy;
    326323    Assert(iov_iter_count(pSrcIter) >= cbToCopy);
    327 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     324# if RTLNX_VER_MIN(3,16,0)
    328325    if (pSrcIter->type & ITER_BVEC) {
    329326        while (cbToCopy > 0) {
     
    364361    size_t const cbTotal = cbToCopy;
    365362    Assert(iov_iter_count(pDstIter) >= cbToCopy);
    366 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     363# if RTLNX_VER_MIN(3,16,0)
    367364    if (pDstIter->type & ITER_BVEC) {
    368365        while (cbToCopy > 0) {
     
    555552*********************************************************************************************************************************/
    556553
    557 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 6)
     554#if RTLNX_VER_MAX(2,6,6)
    558555/** Any writable mappings? */
    559556DECLINLINE(bool) mapping_writably_mapped(struct address_space const *mapping)
    560557{
    561 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 6)
     558# if RTLNX_VER_MIN(2,5,6)
    562559    return !list_empty(&mapping->i_mmap_shared);
    563560# else
     
    568565
    569566
    570 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 12)
     567#if RTLNX_VER_MAX(2,5,12)
    571568/** Missing in 2.4.x, so just stub it for now. */
    572569DECLINLINE(bool) PageWriteback(struct page const *page)
     
    604601*********************************************************************************************************************************/
    605602
    606 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) \
    607  && LINUX_VERSION_CODE <  KERNEL_VERSION(3, 16, 0)
    608 
    609 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
     603#if RTLNX_VER_RANGE(2,6,17,  3,16,0)
     604
     605# if RTLNX_VER_MAX(2,6,30)
    610606#  define LOCK_PIPE(a_pPipe)   do { if ((a_pPipe)->inode) mutex_lock(&(a_pPipe)->inode->i_mutex); } while (0)
    611607#  define UNLOCK_PIPE(a_pPipe) do { if ((a_pPipe)->inode) mutex_unlock(&(a_pPipe)->inode->i_mutex); } while (0)
     
    647643
    648644#endif
    649 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) \
    650  && LINUX_VERSION_CODE <  KERNEL_VERSION(2, 6, 31)
     645#if RTLNX_VER_RANGE(2,6,17,  2,6,31)
    651646
    652647/** Verify pipe buffer content (needed for page-cache to ensure idle page). */
     
    721716static struct pipe_buf_operations vbsf_pipe_buf_ops = {
    722717    .can_merge = 0,
    723 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23)
     718# if RTLNX_VER_MIN(2,6,23)
    724719    .confirm   = vbsf_pipe_buf_confirm,
    725720# else
     
    754749            pPipeBuf->len       = cbThisPage;
    755750            pPipeBuf->offset    = offPg0;
    756 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23)
     751# if RTLNX_VER_MIN(2,6,23)
    757752            pPipeBuf->private   = 0;
    758753# endif
     
    895890
    896891#endif /* 2.6.17 <= LINUX_VERSION_CODE < 2.6.31 */
    897 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) \
    898  && LINUX_VERSION_CODE <  KERNEL_VERSION(3, 16, 0)
     892#if RTLNX_VER_RANGE(2,6,17,  3,16,0)
    899893
    900894/**
     
    10171011                                pPipeBuf = &pPipe->bufs[pPipe->curbuf];
    10181012
    1019 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
     1013# if RTLNX_VER_MAX(2,6,30)
    10201014                                fNeedWakeUp |= pPipe->inode != NULL;
    10211015# else
     
    10921086#endif /* 2.6.17 <= LINUX_VERSION_CODE < 3.16.0 */
    10931087
    1094 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 30) \
    1095  && LINUX_VERSION_CODE <  KERNEL_VERSION(2, 6, 23)
     1088#if RTLNX_VER_RANGE(2,5,30,  2,6,23)
    10961089/**
    10971090 * Our own senfile implementation that does not go via the page cache like
     
    10991092 */
    11001093static ssize_t vbsf_reg_sendfile(struct file *pFile, loff_t *poffFile, size_t cbToSend, read_actor_t pfnActor,
    1101 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8)
     1094# if RTLNX_VER_MIN(2,6,8)
    11021095                                 void *pvUser
    11031096# else
     
    11611154                read_descriptor_t     RdDesc;
    11621155                RdDesc.count    = cbToSend;
    1163 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8)
     1156# if RTLNX_VER_MIN(2,6,8)
    11641157                RdDesc.arg.data = pvUser;
    11651158# else
     
    12901283DECLINLINE(void) vbsf_put_page(struct page *pPage)
    12911284{
    1292 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
     1285#if RTLNX_VER_MIN(4,6,0)
    12931286    put_page(pPage);
    12941287#else
     
    13011294DECLINLINE(void) vbsf_get_page(struct page *pPage)
    13021295{
    1303 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
     1296#if RTLNX_VER_MIN(4,6,0)
    13041297    get_page(pPage);
    13051298#else
     
    14091402     * Check that this is valid user memory that is actually in the kernel range.
    14101403     */
    1411 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) || defined(RHEL_81)
     1404#if RTLNX_VER_MIN(5,0,0) || defined(RHEL_81)
    14121405    if (   access_ok((void *)uPtrFrom, cPages << PAGE_SHIFT)
    14131406        && uPtrFrom >= USER_DS.seg)
     
    14761469static ssize_t vbsf_reg_read_mapped(struct file *file, char /*__user*/ *buf, size_t size, loff_t *off)
    14771470{
    1478 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     1471#if RTLNX_VER_MIN(3,16,0)
    14791472    struct iovec    iov = { .iov_base = buf, .iov_len = size };
    14801473    struct iov_iter iter;
     
    14911484    return cbRet;
    14921485
    1493 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     1486#elif RTLNX_VER_MIN(2,6,19)
    14941487    struct iovec    iov = { .iov_base = buf, .iov_len = size };
    14951488    struct kiocb    kiocb;
     
    17781771                    if (cbToCopy == PAGE_SIZE)
    17791772                        SetPageUptodate(pDstPage);
    1780 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 10)
     1773# if RTLNX_VER_MIN(2,4,10)
    17811774                    mark_page_accessed(pDstPage);
    17821775# endif
     
    19871980        && mapping->nrpages > 0
    19881981        && mapping_writably_mapped(mapping)) {
    1989 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
     1982#if RTLNX_VER_MIN(2,6,32)
    19901983        int err = filemap_fdatawait_range(mapping, pos, pos + size - 1);
    19911984        if (err)
     
    20792072}
    20802073
    2081 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     2074#if RTLNX_VER_MIN(2,6,19)
    20822075
    20832076/**
     
    21472140            SFLOG3(("vbsf_iter_lock_pages: Picked up stashed page: %#zx LB %#zx\n", offPage0, cbChunk));
    21482141        } else {
    2149 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
     2142# if RTLNX_VER_MAX(4,11,0)
    21502143            /*
    21512144             * Copy out our starting point to assist rewinding.
     
    21662159            ssize_t cbSegRet;
    21672160            if (cPages == 0) {
    2168 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
     2161# if RTLNX_VER_MAX(3,19,0)
    21692162                while (!iov_iter_single_seg_count(iter)) /* Old code didn't skip empty segments which caused EFAULTs. */
    21702163                    iov_iter_advance(iter, 0);
     
    22592252         *       and vbsf_lock_user_pages_failed_check_kernel() as well.
    22602253         */
    2261 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
     2254# if RTLNX_VER_MAX(4,11,0)
    22622255        pStash->offFromEnd = iov_iter_count(iter);
    22632256        pStash->Copy       = *iter;
     
    22742267            }
    22752268
    2276 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
     2269# if RTLNX_VER_MIN(3,19,0)
    22772270            pbBuf    = iter->kvec->iov_base + iter->iov_offset;
    22782271# else
     
    23392332    }
    23402333
    2341 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) || LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
     2334# if RTLNX_VER_MIN(4,11,0) || RTLNX_VER_MAX(3,16,0)
    23422335    iov_iter_revert(iter, cbToRewind + cbExtra);
    23432336    return true;
     
    23692362{
    23702363    size_t cPages;
    2371 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     2364# if RTLNX_VER_MIN(3,16,0)
    23722365    if (iter_is_iovec(iter) || (iter->type & ITER_KVEC)) {
    23732366#endif
     
    24292422        if (cPagesSpan > cPages)
    24302423            cPages = cPagesSpan;
    2431 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     2424# if RTLNX_VER_MIN(3,16,0)
    24322425    } else {
    24332426        /* Won't bother with accurate counts for the next two types, just make
     
    25682561 * @param   iter        The I/O vector iterator describing the buffer.
    25692562 */
    2570 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     2563# if RTLNX_VER_MIN(3,16,0)
    25712564static ssize_t vbsf_reg_read_iter(struct kiocb *kio, struct iov_iter *iter)
    25722565# else
     
    25742567# endif
    25752568{
    2576 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
     2569# if RTLNX_VER_MAX(3,16,0)
    25772570    struct vbsf_iov_iter    fake_iter  = VBSF_IOV_ITER_INITIALIZER(cSegs, iov, 0 /*write*/);
    25782571    struct vbsf_iov_iter   *iter       = &fake_iter;
     
    26022595     */
    26032596    if (vbsf_should_use_cached_read(kio->ki_filp, mapping, pSuperInfo)) {
    2604 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     2597# if RTLNX_VER_MIN(3,16,0)
    26052598        return generic_file_read_iter(kio, iter);
    26062599# else
     
    27942787 * @param   iter        The I/O vector iterator describing the buffer.
    27952788 */
    2796 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     2789# if RTLNX_VER_MIN(3,16,0)
    27972790static ssize_t vbsf_reg_write_iter(struct kiocb *kio, struct iov_iter *iter)
    27982791# else
     
    28002793# endif
    28012794{
    2802 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
     2795# if RTLNX_VER_MAX(3,16,0)
    28032796    struct vbsf_iov_iter    fake_iter  = VBSF_IOV_ITER_INITIALIZER(cSegs, iov, 1 /*write*/);
    28042797    struct vbsf_iov_iter   *iter       = &fake_iter;
     
    28112804    struct vbsf_reg_info   *sf_r       = kio->ki_filp->private_data;
    28122805    struct vbsf_super_info *pSuperInfo = VBSF_GET_SUPER_INFO(inode->i_sb);
    2813 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     2806# if RTLNX_VER_MIN(3,16,0)
    28142807    loff_t                  offFile    = kio->ki_pos;
    28152808# endif
    2816 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
     2809# if RTLNX_VER_MIN(4,1,0)
    28172810    bool const              fAppend    = RT_BOOL(kio->ki_flags & IOCB_APPEND);
    28182811# else
     
    28542847        && mapping->nrpages > 0
    28552848        && mapping_writably_mapped(mapping)) {
    2856 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
     2849# if RTLNX_VER_MIN(2,6,32)
    28572850        int err = filemap_fdatawait_range(mapping, offFile, offFile + cbToWrite - 1);
    28582851        if (err)
     
    28902883                            i_size_write(inode, offFile);
    28912884
    2892 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     2885# if RTLNX_VER_MIN(4,11,0)
    28932886                        if ((size_t)cbRet < cbToWrite)
    28942887                            iov_iter_revert(iter, cbToWrite - cbRet);
     
    31293122            && mapping->nrpages > 0
    31303123            /** @todo && last writable handle */ ) {
    3131 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)
     3124#if RTLNX_VER_MIN(2,4,25)
    31323125            if (filemap_fdatawrite(mapping) != -EIO)
    31333126#else
     
    31763169    }
    31773170
    3178 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 8)
     3171#if RTLNX_VER_MIN(2,4,8)
    31793172    return generic_file_llseek(file, off, whence);
    31803173#else
     
    31923185 * well as any host interaction with the file.
    31933186 */
    3194 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0) \
    3195  || (defined(CONFIG_SUSE_KERNEL) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 101) /** @todo figure when exactly */)
     3187#if RTLNX_VER_MIN(3,1,0) \
     3188 || (defined(CONFIG_SUSE_KERNEL) && RTLNX_VER_MIN(3,0,101) /** @todo figure when exactly */)
    31963189static int vbsf_reg_fsync(struct file *file, loff_t start, loff_t end, int datasync)
    31973190{
    3198 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     3191# if RTLNX_VER_MIN(3,16,0)
    31993192    return __generic_file_fsync(file, start, end, datasync);
    32003193# else
     
    32023195# endif
    32033196}
    3204 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
     3197#elif RTLNX_VER_MIN(2,6,35)
    32053198static int vbsf_reg_fsync(struct file *file, int datasync)
    32063199{
     
    32103203static int vbsf_reg_fsync(struct file *file, struct dentry *dentry, int datasync)
    32113204{
    3212 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
     3205# if RTLNX_VER_MIN(2,6,31)
    32133206    return simple_fsync(file, dentry, datasync);
    32143207# else
     
    32193212    /** @todo What about file_fsync()? (<= 2.5.11) */
    32203213
    3221 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 12)
     3214#  if RTLNX_VER_MIN(2,5,12)
    32223215    rc = sync_mapping_buffers(inode->i_mapping);
    32233216    if (   rc == 0
     
    32403233     */
    32413234    rc = fsync_inode_buffers(inode);
    3242 #   if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 10)
     3235#   if RTLNX_VER_MIN(2,4,10)
    32433236    if (rc == 0 && datasync)
    32443237        rc = fsync_inode_data_buffers(inode);
     
    32523245
    32533246
    3254 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
     3247#if RTLNX_VER_MIN(4,5,0)
    32553248/**
    32563249 * Copy a datablock from one file to another on the host side.
     
    32793272        Assert(pInodeInfoDst->u32Magic == SF_INODE_INFO_MAGIC);
    32803273
    3281 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
     3274# if RTLNX_VER_MAX(4,11,0)
    32823275        if (!S_ISREG(pInodeSrc->i_mode) || !S_ISREG(pInodeDst->i_mode))
    32833276            return S_ISDIR(pInodeSrc->i_mode) || S_ISDIR(pInodeDst->i_mode) ? -EISDIR : -EINVAL;
     
    33233316
    33243317/* Generic page fault callback: */
    3325 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     3318# if RTLNX_VER_MIN(4,11,0)
    33263319static vm_fault_t vbsf_vmlog_fault(struct vm_fault *vmf)
    33273320{
     
    33323325    return rc;
    33333326}
    3334 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23)
     3327# elif RTLNX_VER_MIN(2,6,23)
    33353328static int vbsf_vmlog_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
    33363329{
    33373330    int rc;
    3338 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
     3331#  if RTLNX_VER_MIN(4,10,0)
    33393332    SFLOGFLOW(("vbsf_vmlog_fault: vma=%p vmf=%p flags=%#x addr=%p\n", vma, vmf, vmf->flags, vmf->address));
    33403333#  else
     
    33493342
    33503343/* Special/generic page fault handler: */
    3351 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
    3352 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 1)
     3344# if RTLNX_VER_MIN(2,6,26)
     3345# elif RTLNX_VER_MIN(2,6,1)
    33533346static struct page *vbsf_vmlog_nopage(struct vm_area_struct *vma, unsigned long address, int *type)
    33543347{
     
    33723365
    33733366/* Special page fault callback for making something writable: */
    3374 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     3367# if RTLNX_VER_MIN(4,11,0)
    33753368static vm_fault_t vbsf_vmlog_page_mkwrite(struct vm_fault *vmf)
    33763369{
     
    33813374    return rc;
    33823375}
    3383 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     3376# elif RTLNX_VER_MIN(2,6,30)
    33843377static int vbsf_vmlog_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
    33853378{
    33863379    int rc;
    3387 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
     3380#  if RTLNX_VER_MIN(4,10,0)
    33883381    SFLOGFLOW(("vbsf_vmlog_page_mkwrite: vma=%p vmf=%p flags=%#x addr=%p\n", vma, vmf, vmf->flags, vmf->address));
    33893382#  else
     
    33943387    return rc;
    33953388}
    3396 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
     3389# elif RTLNX_VER_MIN(2,6,18)
    33973390static int vbsf_vmlog_page_mkwrite(struct vm_area_struct *vma, struct page *page)
    33983391{
     
    34073400
    34083401/* Special page fault callback for mapping pages: */
    3409 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
     3402# if RTLNX_VER_MIN(4,10,0)
    34103403static void vbsf_vmlog_map_pages(struct vm_fault *vmf, pgoff_t start, pgoff_t end)
    34113404{
     
    34143407    SFLOGFLOW(("vbsf_vmlog_map_pages: returns\n"));
    34153408}
    3416 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
     3409# elif RTLNX_VER_MIN(4,8,0)
    34173410static void vbsf_vmlog_map_pages(struct fault_env *fenv, pgoff_t start, pgoff_t end)
    34183411{
     
    34213414    SFLOGFLOW(("vbsf_vmlog_map_pages: returns\n"));
    34223415}
    3423 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)
     3416# elif RTLNX_VER_MIN(3,15,0)
    34243417static void vbsf_vmlog_map_pages(struct vm_area_struct *vma, struct vm_fault *vmf)
    34253418{
     
    34333426/** Overload template. */
    34343427static struct vm_operations_struct const g_LoggingVmOpsTemplate = {
    3435 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23)
     3428# if RTLNX_VER_MIN(2,6,23)
    34363429    .fault = vbsf_vmlog_fault,
    34373430# endif
    3438 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 25)
     3431# if RTLNX_VER_MAX(2,6,26)
    34393432    .nopage = vbsf_vmlog_nopage,
    34403433# endif
    3441 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
     3434# if RTLNX_VER_MIN(2,6,18)
    34423435    .page_mkwrite = vbsf_vmlog_page_mkwrite,
    34433436# endif
    3444 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0)
     3437# if RTLNX_VER_MIN(3,15,0)
    34453438    .map_pages = vbsf_vmlog_map_pages,
    34463439# endif
     
    34993492    .read            = vbsf_reg_read,
    35003493    .write           = vbsf_reg_write,
    3501 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     3494#if RTLNX_VER_MIN(3,16,0)
    35023495    .read_iter       = vbsf_reg_read_iter,
    35033496    .write_iter      = vbsf_reg_write_iter,
    3504 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     3497#elif RTLNX_VER_MIN(2,6,19)
    35053498    .aio_read        = vbsf_reg_aio_read,
    35063499    .aio_write       = vbsf_reg_aio_write,
     
    35123505    .mmap            = generic_file_mmap,
    35133506#endif
    3514 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
     3507#if RTLNX_VER_RANGE(2,6,17,  2,6,31)
    35153508    .splice_read     = vbsf_splice_read,
    35163509#endif
    3517 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
     3510#if RTLNX_VER_MIN(3,16,0)
    35183511    .splice_write    = iter_file_splice_write,
    3519 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17)
     3512#elif RTLNX_VER_MIN(2,6,17)
    35203513    .splice_write    = vbsf_splice_write,
    35213514#endif
    3522 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 30) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
     3515#if RTLNX_VER_RANGE(2,5,30,  2,6,23)
    35233516    .sendfile        = vbsf_reg_sendfile,
    35243517#endif
    35253518    .llseek          = vbsf_reg_llseek,
    35263519    .fsync           = vbsf_reg_fsync,
    3527 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
     3520#if RTLNX_VER_MIN(4,5,0)
    35283521    .copy_file_range = vbsf_reg_copy_file_range,
    35293522#endif
     
    35353528 */
    35363529struct inode_operations vbsf_reg_iops = {
    3537 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 18)
     3530#if RTLNX_VER_MIN(2,5,18)
    35383531    .getattr    = vbsf_inode_getattr,
    35393532#else
     
    36213614 * fashion.
    36223615 */
    3623 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 52)
     3616#if RTLNX_VER_MIN(2,5,52)
    36243617static int vbsf_writepage(struct page *page, struct writeback_control *wbc)
    36253618#else
     
    36983691
    36993692
    3700 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
     3693#if RTLNX_VER_MIN(2,6,24)
    37013694/**
    37023695 * Called when writing thru the page cache (which we shouldn't be doing).
     
    37243717
    37253718
    3726 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 10)
     3719#if RTLNX_VER_MIN(2,4,10)
    37273720
    37283721# ifdef VBOX_UEK
     
    37743767    .writepage      = vbsf_writepage,
    37753768    /** @todo Need .writepages if we want msync performance...  */
    3776 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 12)
     3769#if RTLNX_VER_MIN(2,5,12)
    37773770    .set_page_dirty = __set_page_dirty_buffers,
    37783771#endif
    3779 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
     3772#if RTLNX_VER_MIN(2,6,24)
    37803773    .write_begin    = vbsf_write_begin,
    37813774    .write_end      = simple_write_end,
    3782 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 45)
     3775#elif RTLNX_VER_MIN(2,5,45)
    37833776    .prepare_write  = simple_prepare_write,
    37843777    .commit_write   = simple_commit_write,
    37853778#endif
    3786 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 10)
     3779#if RTLNX_VER_MIN(2,4,10)
    37873780    .direct_IO      = vbsf_direct_IO,
    37883781#endif
  • trunk/src/VBox/Additions/linux/sharedfolders/utils.c

    r82968 r85698  
    5151
    5252        while (in_bound_len) {
    53 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
     53#if RTLNX_VER_MIN(2,6,31)
    5454            unicode_t uni;
    5555            int cbInEnc = utf8_to_utf32(in, in_bound_len, &uni);
     
    112112            if (cbNlsCodepoint >= 0) {
    113113                char achTmp[16];
    114 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
     114#if RTLNX_VER_MIN(2,6,31)
    115115                int cbUtf8Codepoint = utf32_to_utf8(uc, achTmp, sizeof(achTmp));
    116116#else
     
    145145                    int const cbNlsCodepoint = pSuperInfo->nls->char2uni(&pszNls[offNls], cchNls - offNls, &uc);
    146146                    if (cbNlsCodepoint >= 0) {
    147 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
     147#if RTLNX_VER_MIN(2,6,31)
    148148                        int cbUtf8Codepoint = utf32_to_utf8(uc, pchDst, cchUtf8);
    149149#else
     
    215215 * Convert from VBox to linux time.
    216216 */
    217 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     217#if RTLNX_VER_MAX(2,6,0)
    218218DECLINLINE(void) vbsf_time_to_linux(time_t *pLinuxDst, PCRTTIMESPEC pVBoxSrc)
    219219{
     
    223223}
    224224#else   /* >= 2.6.0 */
    225 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
     225# if RTLNX_VER_MAX(4,18,0)
    226226DECLINLINE(void) vbsf_time_to_linux(struct timespec *pLinuxDst, PCRTTIMESPEC pVBoxSrc)
    227227# else
     
    239239 * Convert from linux to VBox time.
    240240 */
    241 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     241#if RTLNX_VER_MAX(2,6,0)
    242242DECLINLINE(void) vbsf_time_to_vbox(PRTTIMESPEC pVBoxDst, time_t *pLinuxSrc)
    243243{
     
    245245}
    246246#else   /* >= 2.6.0 */
    247 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
     247# if RTLNX_VER_MAX(4,18,0)
    248248DECLINLINE(void) vbsf_time_to_vbox(PRTTIMESPEC pVBoxDst, struct timespec const *pLinuxSrc)
    249249# else
     
    327327        inode->i_fop = &vbsf_reg_fops;
    328328        inode->i_mapping->a_ops = &vbsf_reg_aops;
    329 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 17) \
    330  && LINUX_VERSION_CODE <  KERNEL_VERSION(4, 0, 0)
     329#if RTLNX_VER_RANGE(2,5,17,  4,0,0)
    331330        inode->i_mapping->backing_dev_info = &pSuperInfo->bdi; /* This is needed for mmap. */
    332331#endif
     
    334333    }
    335334
    336 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     335#if RTLNX_VER_MIN(3,5,0)
    337336    inode->i_uid = make_kuid(current_user_ns(), pSuperInfo->uid);
    338337    inode->i_gid = make_kgid(current_user_ns(), pSuperInfo->gid);
     
    343342
    344343    inode->i_size = pObjInfo->cbObject;
    345 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) && !defined(KERNEL_FC6)
     344#if RTLNX_VER_MAX(2,6,19) && !defined(KERNEL_FC6)
    346345    inode->i_blksize = 4096;
    347346#endif
    348 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 11)
     347#if RTLNX_VER_MIN(2,4,11)
    349348    inode->i_blkbits = 12;
    350349#endif
     
    374373    TRACE();
    375374
    376 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
     375#if RTLNX_VER_MIN(4,5,0)
    377376    if (!fInodeLocked)
    378377        inode_lock(pInode);
     
    402401            vbsf_init_inode(pInode, pInodeInfo, pObjInfo, pSuperInfo);
    403402
    404 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
     403#if RTLNX_VER_MIN(4,5,0)
    405404            if (!fInodeLocked)
    406405                inode_unlock(pInode);
     
    467466                    if (mapping && mapping->nrpages > 0) {
    468467                        SFLOGFLOW(("vbsf_update_inode: Invalidating the mapping %s (%#x)\n", pInodeInfo->path->String.ach, fSetAttrs));
    469 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
     468#if RTLNX_VER_MIN(2,6,34)
    470469                        invalidate_mapping_pages(mapping, 0, ~(pgoff_t)0);
    471 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
     470#elif RTLNX_VER_MIN(2,5,41)
    472471                        invalidate_inode_pages(mapping);
    473472#else
     
    487486     * Done.
    488487     */
    489 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
     488#if RTLNX_VER_MIN(4,5,0)
    490489    if (!fInodeLocked)
    491490        inode_unlock(pInode);
     
    627626
    628627
    629 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 18)
     628#if RTLNX_VER_MAX(2,5,18)
    630629/**
    631630 * Revalidate an inode for 2.4.
     
    700699   has inode at all) from these new attributes we derive [kstat] via
    701700   [generic_fillattr] */
    702 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 18)
    703 
    704 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     701#if RTLNX_VER_MIN(2,5,18)
     702
     703# if RTLNX_VER_MIN(4,11,0)
    705704int vbsf_inode_getattr(const struct path *path, struct kstat *kstat, u32 request_mask, unsigned int flags)
    706705# else
     
    709708{
    710709    int            rc;
    711 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     710# if RTLNX_VER_MIN(4,11,0)
    712711    struct dentry *dentry = path->dentry;
    713712# endif
    714713
    715 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     714# if RTLNX_VER_MIN(4,11,0)
    716715    SFLOGFLOW(("vbsf_inode_getattr: dentry=%p request_mask=%#x flags=%#x\n", dentry, request_mask, flags));
    717716# else
     
    719718# endif
    720719
    721 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     720# if RTLNX_VER_MIN(4,11,0)
    722721    /*
    723722     * With the introduction of statx() userland can control whether we
     
    745744
    746745        /* Add birth time. */
    747 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     746# if RTLNX_VER_MIN(4,11,0)
    748747        if (dentry->d_inode) {
    749748            struct vbsf_inode_info *pInodeInfo = VBSF_GET_INODE_INFO(dentry->d_inode);
     
    807806     */
    808807    iattr->ia_valid |= ATTR_FORCE;
    809 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 39) && LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)) || LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) || (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 37) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0))
     808#if (RTLNX_VER_RANGE(3,16,39,  3,17,0)) || RTLNX_VER_MIN(4,9,0) || (RTLNX_VER_RANGE(4,1,37,  4,2,0))
    810809    rc = setattr_prepare(dentry, iattr);
    811810#else
     
    818817         */
    819818        unsigned fAttrs = iattr->ia_valid;
    820 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)
     819#if RTLNX_VER_MIN(2,6,15)
    821820        fAttrs &= ~ATTR_FILE;
    822821#endif
    823822        if (   fAttrs == (ATTR_SIZE | ATTR_MTIME | ATTR_CTIME)
    824 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
     823#if RTLNX_VER_MIN(2,6,24)
    825824            || (fAttrs & (ATTR_OPEN | ATTR_SIZE)) == (ATTR_OPEN | ATTR_SIZE)
    826825#endif
     
    10671066            in += nb;
    10681067
    1069 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31)
     1068#if RTLNX_VER_MIN(2,6,31)
    10701069            nb = utf32_to_utf8(uni, out, out_bound_len);
    10711070#else
     
    11131112 * @note Caller holds no relevant locks, just a dentry reference.
    11141113 */
    1115 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
     1114#if RTLNX_VER_MIN(3,6,0)
    11161115static int vbsf_dentry_revalidate(struct dentry *dentry, unsigned flags)
    1117 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     1116#elif RTLNX_VER_MIN(2,6,0)
    11181117static int vbsf_dentry_revalidate(struct dentry *dentry, struct nameidata *nd)
    11191118#else
     
    11211120#endif
    11221121{
    1123 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)
     1122#if RTLNX_VER_RANGE(2,6,0,  3,6,0)
    11241123    int const flags = nd ? nd->flags : 0;
    11251124#endif
     
    11391138     *
    11401139     */
    1141 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
     1140#if RTLNX_VER_MIN(2,6,38)
    11421141    if (flags & LOOKUP_RCU) {
    11431142        rc = -ECHILD;
     
    11811180             * later point).
    11821181             */
    1183 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     1182#if RTLNX_VER_MIN(2,6,28)
    11841183            if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
    1185 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 75)
     1184#elif RTLNX_VER_MIN(2,5,75)
    11861185            if (flags & LOOKUP_CREATE)
    11871186#else
     
    12141213
    12151214/** For logging purposes only. */
    1216 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
     1215# if RTLNX_VER_MIN(2,6,38)
    12171216static int vbsf_dentry_delete(const struct dentry *pDirEntry)
    12181217# else
     
    12241223}
    12251224
    1226 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
     1225# if RTLNX_VER_MIN(4,8,0)
    12271226/** For logging purposes only. */
    12281227static int vbsf_dentry_init(struct dentry *pDirEntry)
     
    12441243#ifdef SFLOG_ENABLED
    12451244    .d_delete = vbsf_dentry_delete,
    1246 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
     1245# if RTLNX_VER_MIN(4,8,0)
    12471246    .d_init = vbsf_dentry_init,
    12481247# endif
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c

    r85432 r85698  
    4646#include "revision-generated.h"
    4747#include "product-generated.h"
    48 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
     48#if RTLNX_VER_MIN(5,0,0)
    4949# include <uapi/linux/mount.h> /* for MS_REMOUNT */
    50 #elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
     50#elif RTLNX_VER_MAX(3,3,0)
    5151# include <linux/mount.h>
    5252#endif
    5353#include <linux/seq_file.h>
    5454#include <linux/vfs.h>
    55 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 62) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
     55#if RTLNX_VER_RANGE(2,5,62,  5,8,0)
    5656# include <linux/vermagic.h>
    5757#endif
     
    356356{
    357357    int rc = 0;
    358 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     358#if RTLNX_VER_MIN(2,6,0)
    359359    /* Each new shared folder map gets a new uint64_t identifier,
    360360     * allocated in sequence.  We ASSUME the sequence will not wrap. */
    361 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
     361# if RTLNX_VER_MIN(2,6,26)
    362362    static uint64_t s_u64Sequence = 0;
    363363    uint64_t idSeqMine = ASMAtomicIncU64(&s_u64Sequence);
     
    365365    struct backing_dev_info *bdi;
    366366
    367 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
     367# if RTLNX_VER_RANGE(4,0,0,  4,2,0)
    368368    pSuperInfo->bdi_org = sb->s_bdi;
    369369# endif
    370370
    371 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
     371# if RTLNX_VER_MIN(4,12,0)
    372372    rc = super_setup_bdi_name(sb, "vboxsf-%llu", (unsigned long long)idSeqMine);
    373373    if (!rc)
     
    381381    bdi->ra_pages = 0;                      /* No readahead */
    382382
    383 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 12)
     383# if RTLNX_VER_MIN(2,6,12)
    384384    bdi->capabilities = 0
    385385#  ifdef BDI_CAP_MAP_DIRECT
     
    399399#  endif
    400400#  ifdef BDI_CAP_STRICTLIMIT
    401 #   if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) /* Trouble with 3.16.x/debian8.  Process stops after dirty page throttling.
     401#   if RTLNX_VER_MIN(4,19,0) /* Trouble with 3.16.x/debian8.  Process stops after dirty page throttling.
    402402                                                       * Only tested successfully with 4.19.  Maybe skip altogether? */
    403403                      | BDI_CAP_STRICTLIMIT;
     
    414414# endif /* >= 2.6.12 */
    415415
    416 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
     416# if RTLNX_VER_RANGE(2,6,24,  4,12,0)
    417417    rc = bdi_init(&pSuperInfo->bdi);
    418 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
     418#  if RTLNX_VER_MIN(2,6,26)
    419419    if (!rc)
    420420        rc = bdi_register(&pSuperInfo->bdi, NULL, "vboxsf-%llu", (unsigned long long)idSeqMine);
     
    422422# endif  /* 4.11.0 > version >= 2.6.24 */
    423423
    424 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
     424# if RTLNX_VER_RANGE(2,6,34,  4,12,0)
    425425    if (!rc)
    426426        sb->s_bdi = bdi;
     
    437437static void vbsf_done_backing_dev(struct super_block *sb, struct vbsf_super_info *pSuperInfo)
    438438{
    439 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) && LINUX_VERSION_CODE <= KERNEL_VERSION(4, 12, 0)
     439#if RTLNX_VER_RANGE(2,6,24,  4,13,0)
    440440    bdi_destroy(&pSuperInfo->bdi);    /* includes bdi_unregister() */
    441441
    442442    /* Paranoia: Make sb->s_bdi not point at pSuperInfo->bdi, in case someone
    443443                 trouches it after this point (we may screw up something).  */
    444 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
     444# if RTLNX_VER_RANGE(4,0,0,  4,2,0)
    445445    sb->s_bdi = pSuperInfo->bdi_org; /* (noop_backing_dev_info is not exported) */
    446 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
     446# elif RTLNX_VER_RANGE(2,6,34,  4,10,0)
    447447    sb->s_bdi = &noop_backing_dev_info;
    448448# endif
     
    491491             * Note! ls -la does display '.' and '..' entries with st_ino == 0, so root is #1.
    492492             */
    493 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)
     493#if RTLNX_VER_MIN(2,4,25)
    494494            struct inode *iroot = iget_locked(sb, 1);
    495495#else
     
    500500                VBSF_SET_INODE_INFO(iroot, sf_i);
    501501
    502 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 25)
     502#if RTLNX_VER_MIN(2,4,25)
    503503                unlock_new_inode(iroot);
    504504#endif
     
    507507                 * Now make it a root inode.
    508508                 */
    509 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
     509#if RTLNX_VER_MIN(3,4,0)
    510510                sb->s_root = d_make_root(iroot);
    511511#else
     
    518518
    519519                SFLOGRELBOTH(("vboxsf: d_make_root failed!\n"));
    520 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) /* d_make_root calls iput */
     520#if RTLNX_VER_MAX(3,4,0) /* d_make_root calls iput */
    521521                iput(iroot);
    522522#endif
     
    582582        sb->s_magic     = 0xface;
    583583        sb->s_blocksize = 1024;
    584 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 3)
     584#if RTLNX_VER_MIN(2,4,3)
    585585        /* Required for seek/sendfile (see 'loff_t max' in fs/read_write.c / do_sendfile()). */
    586586# if defined MAX_LFS_FILESIZE
     
    592592# endif
    593593#endif
    594 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
     594#if RTLNX_VER_MIN(2,6,11)
    595595        sb->s_time_gran = 1; /* This might be a little optimistic for windows hosts, where it should be 100. */
    596596#endif
    597597        sb->s_op        = &g_vbsf_super_ops;
    598 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
     598#if RTLNX_VER_MIN(2,6,38)
    599599        sb->s_d_op      = &vbsf_dentry_ops;
    600600#endif
     
    629629 * We must free the inode info structure here.
    630630 */
    631 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
     631#if RTLNX_VER_MIN(2,6,36)
    632632static void vbsf_evict_inode(struct inode *inode)
    633633#else
     
    642642     * Flush stuff.
    643643     */
    644 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
     644#if RTLNX_VER_MIN(2,6,36)
    645645    truncate_inode_pages(&inode->i_data, 0);
    646 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     646# if RTLNX_VER_MIN(3,5,0)
    647647    clear_inode(inode);
    648648# else
     
    673673   hence we can't do anything here, and let lookup/whatever with the
    674674   job to properly fill then [inode] */
    675 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
     675#if RTLNX_VER_MAX(2,6,25)
    676676static void vbsf_read_inode(struct inode *inode)
    677677{
     
    696696 * Get file system statistics.
    697697 */
    698 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
     698#if RTLNX_VER_MIN(2,6,18)
    699699static int vbsf_statfs(struct dentry *dentry, struct kstatfs *stat)
    700 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 73)
     700#elif RTLNX_VER_MIN(2,5,73)
    701701static int vbsf_statfs(struct super_block *sb, struct kstatfs *stat)
    702702#else
     
    704704#endif
    705705{
    706 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
     706#if RTLNX_VER_MIN(2,6,18)
    707707    struct super_block *sb = dentry->d_inode->i_sb;
    708708#endif
     
    716716            stat->f_type   = UINT32_C(0x786f4256); /* 'VBox' little endian */
    717717            stat->f_bsize  = pVolInfo->ulBytesPerAllocationUnit;
    718 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 73)
     718#if RTLNX_VER_MIN(2,5,73)
    719719            stat->f_frsize = pVolInfo->ulBytesPerAllocationUnit;
    720720#endif
     
    731731            stat->f_fsid.val[1] = 0;
    732732            stat->f_namelen = 255;
    733 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
     733#if RTLNX_VER_MIN(2,6,36)
    734734            stat->f_flags = 0; /* not valid */
    735735#endif
     
    746746static int vbsf_remount_fs(struct super_block *sb, int *flags, char *data)
    747747{
    748 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 23)
     748#if RTLNX_VER_MIN(2,4,23)
    749749    struct vbsf_super_info *pSuperInfo = pSuperInfo = VBSF_GET_SUPER_INFO(sb);
    750750    struct vbsf_inode_info *sf_i;
     
    774774    /*unlock_new_inode(iroot); */
    775775    return 0;
    776 #else  /* LINUX_VERSION_CODE < 2.4.23 */
     776#else  /* < 2.4.23 */
    777777    return -ENOSYS;
    778 #endif /* LINUX_VERSION_CODE < 2.4.23 */
     778#endif /* < 2.4.23 */
    779779}
    780780
     
    786786 * the the 'szTag' option value it sets on its mount.
    787787 */
    788 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
     788#if RTLNX_VER_MAX(3,3,0)
    789789static int vbsf_show_options(struct seq_file *m, struct vfsmount *mnt)
    790790#else
     
    792792#endif
    793793{
    794 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
     794#if RTLNX_VER_MAX(3,3,0)
    795795    struct super_block     *sb         = mnt->mnt_sb;
    796796#else
     
    845845 */
    846846static struct super_operations g_vbsf_super_ops = {
    847 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
     847#if RTLNX_VER_MAX(2,6,36)
    848848    .clear_inode  = vbsf_clear_inode,
    849849#else
    850850    .evict_inode  = vbsf_evict_inode,
    851851#endif
    852 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
     852#if RTLNX_VER_MAX(2,6,25)
    853853    .read_inode   = vbsf_read_inode,
    854854#endif
     
    865865*********************************************************************************************************************************/
    866866
    867 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 4)
     867#if RTLNX_VER_MIN(2,5,4)
    868868
    869869static int vbsf_read_super_26(struct super_block *sb, void *data, int flags)
     
    879879}
    880880
    881 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
     881# if RTLNX_VER_MIN(2,6,39)
     882static struct dentry *sf_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data)
     883{
     884    TRACE();
     885    return mount_nodev(fs_type, flags, data, vbsf_read_super_26);
     886}
     887# elif RTLNX_VER_MIN(2,6,18)
     888static int vbsf_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct vfsmount *mnt)
     889{
     890    TRACE();
     891    return get_sb_nodev(fs_type, flags, data, vbsf_read_super_26, mnt);
     892}
     893# else /* < 2.6.18 */
    882894static struct super_block *vbsf_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data)
    883895{
     
    885897    return get_sb_nodev(fs_type, flags, data, vbsf_read_super_26);
    886898}
    887 # elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
    888 static int vbsf_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, struct vfsmount *mnt)
    889 {
    890     TRACE();
    891     return get_sb_nodev(fs_type, flags, data, vbsf_read_super_26, mnt);
    892 }
    893 # else /* LINUX_VERSION_CODE >= 2.6.39 */
    894 static struct dentry *sf_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data)
    895 {
    896     TRACE();
    897     return mount_nodev(fs_type, flags, data, vbsf_read_super_26);
    898 }
    899 # endif /* LINUX_VERSION_CODE >= 2.6.39 */
     899# endif
    900900
    901901/**
     
    905905    .owner = THIS_MODULE,
    906906    .name = "vboxsf",
    907 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
     907# if RTLNX_VER_MIN(2,6,39)
     908    .mount = sf_mount,
     909# else
    908910    .get_sb = vbsf_get_sb,
    909 # else
    910     .mount = sf_mount,
    911911# endif
    912912    .kill_sb = kill_anon_super
    913913};
    914914
    915 #else  /* LINUX_VERSION_CODE < 2.5.4 */
     915#else  /* < 2.5.4 */
    916916
    917917static struct super_block *vbsf_read_super_24(struct super_block *sb, void *data, int flags)
     
    931931static DECLARE_FSTYPE(g_vboxsf_fs_type, "vboxsf", vbsf_read_super_24, 0);
    932932
    933 #endif /* LINUX_VERSION_CODE < 2.5.4 */
     933#endif /* < 2.5.4 */
    934934
    935935
     
    10541054 * Module parameters.
    10551055 */
    1056 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 52)
     1056#if RTLNX_VER_MIN(2,5,52)
    10571057module_param_named(follow_symlinks, g_fFollowSymlinks, int, 0);
    10581058MODULE_PARM_DESC(follow_symlinks,
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h

    r82968 r85698  
    4646#include <VBox/log.h>
    4747
    48 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     48#if RTLNX_VER_MIN(2,6,0)
    4949# include <linux/backing-dev.h>
    5050#endif
     
    8383 * inode compatibility glue.
    8484 */
    85 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     85#if RTLNX_VER_MAX(2,6,0)
    8686
    8787DECLINLINE(loff_t) i_size_read(struct inode *pInode)
     
    9999#endif /* < 2.6.0 */
    100100
    101 #if  LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0) \
     101#if  RTLNX_VER_MAX(3,2,0) \
    102102  && (!defined(RHEL_MAJOR) || RHEL_MAJOR != 6 || RHEL_MINOR < 10)
    103103DECLINLINE(void) set_nlink(struct inode *pInode, unsigned int cLinks)
     
    150150    /** Mount tag for VBoxService automounter.  @since 6.0 */
    151151    char                    szTag[32];
    152 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)
     152#if RTLNX_VER_RANGE(2,6,0,  4,12,0)
    153153    /** The backing device info structure. */
    154154    struct backing_dev_info bdi;
     
    160160    /** The time to live for inode information in milliseconds, for /proc/mounts. */
    161161    int32_t                 msInodeTTL;
    162 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
     162#if RTLNX_VER_RANGE(4,0,0,  4,2,0)
    163163    /** 4.0 and 4.1 are missing noop_backing_dev_info export, so take down the
    164164     *  initial value so we can restore it in vbsf_done_backing_dev(). (paranoia) */
     
    169169/* Following casts are here to prevent assignment of void * to
    170170   pointers of arbitrary type */
    171 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     171#if RTLNX_VER_MAX(2,6,0)
    172172# define VBSF_GET_SUPER_INFO(sb)                ((struct vbsf_super_info *)(sb)->u.generic_sbp)
    173173# define VBSF_SET_SUPER_INFO(sb, a_pSuperInfo)  do { (sb)->u.generic_sbp = a_pSuperInfo; } while (0)
     
    249249};
    250250
    251 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) || defined(KERNEL_FC6)
     251#if RTLNX_VER_MIN(2,6,19) || defined(KERNEL_FC6)
    252252/* FC6 kernel 2.6.18, vanilla kernel 2.6.19+ */
    253253# define VBSF_GET_INODE_INFO(i)       ((struct vbsf_inode_info *) (i)->i_private)
     
    265265extern int  vbsf_inode_revalidate_worker(struct dentry *dentry, bool fForced, bool fInodeLocked);
    266266extern int  vbsf_inode_revalidate_with_handle(struct dentry *dentry, SHFLHANDLE hHostFile, bool fForced, bool fInodeLocked);
    267 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 18)
    268 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     267#if RTLNX_VER_MIN(2,5,18)
     268# if RTLNX_VER_MIN(4,11,0)
    269269extern int  vbsf_inode_getattr(const struct path *path, struct kstat *kstat, u32 request_mask, unsigned int query_flags);
    270270# else
     
    420420
    421421/** Macro for getting the dentry for a struct file. */
    422 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
     422#if RTLNX_VER_MIN(4,6,0)
    423423# define VBSF_GET_F_DENTRY(f)   file_dentry(f)
    424 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     424#elif RTLNX_VER_MIN(2,6,20)
    425425# define VBSF_GET_F_DENTRY(f)   (f->f_path.dentry)
    426426#else
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r85552 r85698  
    5555
    5656#elif defined(RT_OS_LINUX)
    57 #   include <linux/version.h>
    58 #   if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
     57#   include <iprt/linux/version.h>
     58#   if RTLNX_VER_MIN(2,6,33)
    5959#    include <generated/autoconf.h>
    6060#   else
     
    6565#   if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
    6666#       define MODVERSIONS
    67 #       if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 71)
     67#       if RTLNX_VER_MAX(2,5,71)
    6868#           include <linux/modversions.h>
    6969#       endif
    7070#   endif
    7171#   ifndef KBUILD_STR
    72 #       if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
     72#       if RTLNX_VER_MAX(2,6,16)
    7373#            define KBUILD_STR(s) s
    7474#       else
     
    7979#   include <linux/spinlock.h>
    8080#   include <linux/slab.h>
    81 #   if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     81#   if RTLNX_VER_MIN(2,6,27)
    8282#       include <linux/semaphore.h>
    8383#   else /* older kernels */
  • trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c

    r85505 r85698  
    4747
    4848/** @todo figure out the exact version number */
    49 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
     49#if RTLNX_VER_MIN(2,6,16)
    5050# include <iprt/power.h>
    5151# define VBOX_WITH_SUSPEND_NOTIFICATION
     
    5757# include <linux/platform_device.h>
    5858#endif
    59 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)) && defined(SUPDRV_WITH_MSR_PROBER)
     59#if (RTLNX_VER_MIN(2,6,28)) && defined(SUPDRV_WITH_MSR_PROBER)
    6060# define SUPDRV_LINUX_HAS_SAFE_MSR_API
    6161# include <asm/msr.h>
     
    7272/* check kernel version */
    7373# ifndef SUPDRV_AGNOSTIC
    74 #  if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     74#  if RTLNX_VER_MAX(2,6,0)
    7575#   error Unsupported kernel version!
    7676#  endif
     
    112112#ifdef VBOX_WITH_SUSPEND_NOTIFICATION
    113113static int  VBoxDrvProbe(struct platform_device *pDev);
    114 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     114# if RTLNX_VER_MIN(2,6,30)
    115115static int  VBoxDrvSuspend(struct device *pDev);
    116116static int  VBoxDrvResume(struct device *pDev);
     
    140140#define DEVICE_NAME_USR     "vboxdrvu"
    141141
    142 #if (defined(RT_ARCH_AMD64) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)
     142#if (defined(RT_ARCH_AMD64) && RTLNX_VER_MAX(2,6,23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)
    143143/**
    144144 * Memory for the executable memory heap (in IPRT).
     
    203203    name:       DEVICE_NAME_SYS,
    204204    fops:       &gFileOpsVBoxDrvSys,
    205 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)
     205# if RTLNX_VER_MAX(2,6,18)
    206206    devfs_name: DEVICE_NAME_SYS,
    207207# endif
     
    213213    name:       DEVICE_NAME_USR,
    214214    fops:       &gFileOpsVBoxDrvUsr,
    215 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)
     215# if RTLNX_VER_MAX(2,6,18)
    216216    devfs_name: DEVICE_NAME_USR,
    217217# endif
     
    220220
    221221#ifdef VBOX_WITH_SUSPEND_NOTIFICATION
    222 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     222# if RTLNX_VER_MIN(2,6,30)
    223223static struct dev_pm_ops gPlatformPMOps =
    224224{
     
    233233{
    234234    .probe = VBoxDrvProbe,
    235 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
     235# if RTLNX_VER_MAX(2,6,30)
    236236    .suspend = VBoxDrvSuspend,
    237237    .resume  = VBoxDrvResume,
     
    241241    {
    242242        .name = "vboxdrv",
    243 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     243# if RTLNX_VER_MIN(2,6,30)
    244244        .pm = &gPlatformPMOps,
    245245# endif
     
    260260DECLINLINE(RTUID) vboxdrvLinuxUid(void)
    261261{
    262 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
    263 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     262#if RTLNX_VER_MIN(2,6,29)
     263# if RTLNX_VER_MIN(3,5,0)
    264264    return from_kuid(current_user_ns(), current->cred->uid);
    265265# else
     
    273273DECLINLINE(RTGID) vboxdrvLinuxGid(void)
    274274{
    275 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
    276 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     275#if RTLNX_VER_MIN(2,6,29)
     276# if RTLNX_VER_MIN(3,5,0)
    277277    return from_kgid(current_user_ns(), current->cred->gid);
    278278# else
     
    286286DECLINLINE(RTUID) vboxdrvLinuxEuid(void)
    287287{
    288 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
    289 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     288#if RTLNX_VER_MIN(2,6,29)
     289# if RTLNX_VER_MIN(3,5,0)
    290290    return from_kuid(current_user_ns(), current->cred->euid);
    291291# else
     
    332332        if (RT_SUCCESS(rc))
    333333        {
    334 #if (defined(RT_ARCH_AMD64) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)
     334#if (defined(RT_ARCH_AMD64) && RTLNX_VER_MAX(2,6,23)) || defined(VBOX_WITH_TEXT_MODMEM_HACK)
    335335# ifdef VBOX_WITH_TEXT_MODMEM_HACK
    336336            set_memory_x(&g_abExecMemory[0], sizeof(g_abExecMemory) / PAGE_SIZE);
     
    516516 *                      Ignored.
    517517 */
    518 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) && !defined(DOXYGEN_RUNNING)
     518# if RTLNX_VER_MIN(2,6,30) && !defined(DOXYGEN_RUNNING)
    519519static int VBoxDrvSuspend(struct device *pDev)
    520520# else
     
    531531 * @param   pDev        Pointer to the platform device.
    532532 */
    533 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     533# if RTLNX_VER_MIN(2,6,30)
    534534static int VBoxDrvResume(struct device *pDev)
    535535# else
     
    757757RTCCUINTREG VBOXCALL supdrvOSChangeCR4(RTCCUINTREG fOrMask, RTCCUINTREG fAndMask)
    758758{
    759 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
     759#if RTLNX_VER_MIN(5,8,0)
    760760    RTCCUINTREG const uOld = __read_cr4();
    761 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0)
     761#elif RTLNX_VER_MIN(3,20,0)
    762762    RTCCUINTREG const uOld = this_cpu_read(cpu_tlbstate.cr4);
    763763#else
     
    767767    if (uNew != uOld)
    768768    {
    769 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
     769#if RTLNX_VER_MIN(5,8,0)
    770770        ASMSetCR4(uNew);
    771 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0)
     771#elif RTLNX_VER_MIN(3,20,0)
    772772        this_cpu_write(cpu_tlbstate.cr4, uNew);
    773773        __write_cr4(uNew);
     
    11211121
    11221122        /* Nobody waiting and no exit function. */
    1123 #  if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
     1123#  if RTLNX_VER_MAX(3,13,0)
    11241124        pMyMod->waiter              = NULL;
    11251125#  endif
     
    11281128        /* References, very important as we must not allow the module
    11291129           to be unloaded using rmmod. */
    1130 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
     1130#  if RTLNX_VER_MIN(3,19,0)
    11311131        atomic_set(&pMyMod->refcnt, 42);
    11321132#  else
     
    12131213        mutex_unlock(&module_mutex);
    12141214
    1215 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
     1215# if RTLNX_VER_MAX(3,19,0)
    12161216        free_percpu(pMyMod->refptr);
    12171217# endif
     
    14321432    fFlags |= SUPKERNELFEATURES_GDT_READ_ONLY;
    14331433#endif
    1434 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
     1434#if RTLNX_VER_MIN(4,12,0)
    14351435    fFlags |= SUPKERNELFEATURES_GDT_NEED_WRITABLE;
    14361436#endif
     
    14471447int VBOXCALL    supdrvOSGetCurrentGdtRw(RTHCUINTPTR *pGdtRw)
    14481448{
    1449 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
     1449#if RTLNX_VER_MIN(4,12,0)
    14501450    *pGdtRw = (RTHCUINTPTR)get_current_gdt_rw();
    14511451    return VINF_SUCCESS;
  • trunk/src/VBox/HostDrivers/Support/linux/files_vboxdrv

    r85523 r85698  
    7373    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
    7474    ${PATH_ROOT}/include/iprt/x86.h=>include/iprt/x86.h \
     75    ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \
    7576    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
    7677    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c

    r82968 r85698  
    7676static int VBoxNetAdpLinuxOpen(struct inode *pInode, struct file *pFilp);
    7777static int VBoxNetAdpLinuxClose(struct inode *pInode, struct file *pFilp);
    78 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
     78#if RTLNX_VER_MAX(2,6,36)
    7979static int VBoxNetAdpLinuxIOCtl(struct inode *pInode, struct file *pFilp,
    8080                                unsigned int uCmd, unsigned long ulArg);
    81 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
     81#else  /* >= 2,6,36 */
    8282static long VBoxNetAdpLinuxIOCtlUnlocked(struct file *pFilp,
    8383                                         unsigned int uCmd, unsigned long ulArg);
    84 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
     84#endif /* >= 2,6,36 */
    8585
    8686static void vboxNetAdpEthGetDrvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
    87 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
     87#if RTLNX_VER_MIN(4,20,0)
    8888static int vboxNetAdpEthGetLinkSettings(struct net_device *pNetDev, struct ethtool_link_ksettings *pLinkSettings);
    89 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */
     89#else  /* < 4,20,0 */
    9090static int vboxNetAdpEthGetSettings(struct net_device *dev, struct ethtool_cmd *cmd);
    91 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */
     91#endif /* < 4,20,0 */
    9292
    9393
     
    113113    open:       VBoxNetAdpLinuxOpen,
    114114    release:    VBoxNetAdpLinuxClose,
    115 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
     115#if RTLNX_VER_MAX(2,6,36)
    116116    ioctl:      VBoxNetAdpLinuxIOCtl,
    117 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
     117#else /* RTLNX_VER_MIN(2,6,36) */
    118118    unlocked_ioctl: VBoxNetAdpLinuxIOCtlUnlocked,
    119 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
     119#endif /* RTLNX_VER_MIN(2,6,36) */
    120120};
    121121
     
    126126    name:       VBOXNETADP_CTL_DEV_NAME,
    127127    fops:       &gFileOpsVBoxNetAdp,
    128 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)
     128# if RTLNX_VER_MAX(2,6,18)
    129129    devfs_name: VBOXNETADP_CTL_DEV_NAME
    130130# endif
    131131};
    132132
    133 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     133# if RTLNX_VER_MIN(2,6,19)
    134134static const struct ethtool_ops gEthToolOpsVBoxNetAdp =
    135135# else
     
    138138{
    139139    .get_drvinfo        = vboxNetAdpEthGetDrvinfo,
    140 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
     140# if RTLNX_VER_MIN(4,20,0)
    141141    .get_link_ksettings = vboxNetAdpEthGetLinkSettings,
    142 # else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */
     142# else
    143143    .get_settings       = vboxNetAdpEthGetSettings,
    144 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */
     144# endif
    145145    .get_link           = ethtool_op_get_link,
    146146};
     
    174174    pPriv->Stats.tx_packets++;
    175175    pPriv->Stats.tx_bytes += pSkb->len;
    176 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
     176#if RTLNX_VER_MAX(2,6,31)
    177177    /* Update transmission time stamp. */
    178178    pNetDev->trans_start = jiffies;
     
    214214
    215215
    216 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
     216# if RTLNX_VER_MIN(4,20,0)
    217217/* ethtool_ops::get_link_ksettings */
    218218static int vboxNetAdpEthGetLinkSettings(struct net_device *pNetDev, struct ethtool_link_ksettings *pLinkSettings)
     
    230230    return 0;
    231231}
    232 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */
     232#else /* RTLNX_VER_MAX(4,20,0) */
    233233/* ethtool_ops::get_settings */
    234234static int vboxNetAdpEthGetSettings(struct net_device *pNetDev, struct ethtool_cmd *cmd)
     
    236236    cmd->supported      = 0;
    237237    cmd->advertising    = 0;
    238 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     238#if RTLNX_VER_MIN(2,6,27)
    239239    ethtool_cmd_speed_set(cmd, SPEED_10);
    240240#else
     
    250250    return 0;
    251251}
    252 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */
    253 
    254 
    255 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     252#endif /* RTLNX_VER_MAX(4,20,0) */
     253
     254
     255#if RTLNX_VER_MIN(2,6,29)
    256256static const struct net_device_ops vboxNetAdpNetdevOps = {
    257257    .ndo_open               = vboxNetAdpLinuxOpen,
     
    267267
    268268    ether_setup(pNetDev);
    269 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     269#if RTLNX_VER_MIN(2,6,29)
    270270    pNetDev->netdev_ops = &vboxNetAdpNetdevOps;
    271 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
     271#else /* RTLNX_VER_MAX(2,6,29) */
    272272    pNetDev->open = vboxNetAdpLinuxOpen;
    273273    pNetDev->stop = vboxNetAdpLinuxStop;
    274274    pNetDev->hard_start_xmit = vboxNetAdpLinuxXmit;
    275275    pNetDev->get_stats = vboxNetAdpLinuxGetStats;
    276 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
     276#endif /* RTLNX_VER_MAX(2,6,29) */
    277277
    278278    pNetDev->ethtool_ops = &gEthToolOpsVBoxNetAdp;
     
    291291    pNetDev = alloc_netdev(sizeof(VBOXNETADPPRIV),
    292292                           pThis->szName[0] ? pThis->szName : VBOXNETADP_LINUX_NAME,
    293 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
     293#if RTLNX_VER_MIN(3,17,0)
    294294                           NET_NAME_UNKNOWN,
    295295#endif
     
    391391 * @param   ulArg       The argument specified to ioctl().
    392392 */
    393 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
     393#if RTLNX_VER_MAX(2,6,36)
    394394static int VBoxNetAdpLinuxIOCtl(struct inode *pInode, struct file *pFilp,
    395395                                unsigned int uCmd, unsigned long ulArg)
    396 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
     396#else /* RTLNX_VER_MIN(2,6,36) */
    397397static long VBoxNetAdpLinuxIOCtlUnlocked(struct file *pFilp,
    398398                                         unsigned int uCmd, unsigned long ulArg)
    399 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
     399#endif /* RTLNX_VER_MIN(2,6,36) */
    400400{
    401401    VBOXNETADPREQ Req;
  • trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/files_vboxnetadp

    r82968 r85698  
    6666    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
    6767    ${PATH_ROOT}/include/iprt/x86.h=>include/iprt/x86.h \
     68    ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \
    6869    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
    6970    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

    r85588 r85698  
    3535#include "revision-generated.h"
    3636#include "product-generated.h"
    37 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24)
     37#if RTLNX_VER_MIN(2,6,24)
    3838#include <linux/nsproxy.h>
    3939#endif
     
    4646#include <linux/ip.h>
    4747#include <linux/if_vlan.h>
    48 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
     48#if RTLNX_VER_MIN(4,5,0)
    4949#include <uapi/linux/pkt_cls.h>
    5050#endif
     
    9090#endif
    9191
    92 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)
     92#if RTLNX_VER_MIN(3,11,0)
    9393# define VBOX_NETDEV_NOTIFIER_INFO_TO_DEV(ptr) netdev_notifier_info_to_dev(ptr)
    9494#else
     
    9696#endif
    9797
    98 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     98#if RTLNX_VER_MIN(3,5,0)
    9999# define VBOX_SKB_KMAP_FRAG(frag) kmap_atomic(skb_frag_page(frag))
    100100# define VBOX_SKB_KUNMAP_FRAG(vaddr) kunmap_atomic(vaddr)
    101101#else
    102 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
     102# if RTLNX_VER_MIN(3,2,0)
    103103#  define VBOX_SKB_KMAP_FRAG(frag) kmap_atomic(skb_frag_page(frag), KM_SKB_DATA_SOFTIRQ)
    104104#  define VBOX_SKB_KUNMAP_FRAG(vaddr) kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ)
     
    109109#endif
    110110
    111 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
     111#if RTLNX_VER_MIN(2,6,34)
    112112# define VBOX_NETDEV_NAME(dev)              netdev_name(dev)
    113113#else
     
    115115#endif
    116116
    117 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
     117#if RTLNX_VER_MIN(2,6,25)
    118118# define VBOX_IPV4_IS_LOOPBACK(addr)        ipv4_is_loopback(addr)
    119119# define VBOX_IPV4_IS_LINKLOCAL_169(addr)   ipv4_is_linklocal_169(addr)
     
    123123#endif
    124124
    125 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
     125#if RTLNX_VER_MIN(2,6,22)
    126126# define VBOX_SKB_RESET_NETWORK_HDR(skb)    skb_reset_network_header(skb)
    127127# define VBOX_SKB_RESET_MAC_HDR(skb)        skb_reset_mac_header(skb)
     
    133133#endif
    134134
    135 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     135#if RTLNX_VER_MIN(2,6,19)
    136136# define VBOX_SKB_CHECKSUM_HELP(skb)        skb_checksum_help(skb)
    137137#else
    138138# define CHECKSUM_PARTIAL                   CHECKSUM_HW
    139 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
     139# if RTLNX_VER_MIN(2,6,10)
    140140#  define VBOX_SKB_CHECKSUM_HELP(skb)       skb_checksum_help(skb, 0)
    141141# else
    142 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 7)
     142#  if RTLNX_VER_MIN(2,6,7)
    143143#   define VBOX_SKB_CHECKSUM_HELP(skb)      skb_checksum_help(&skb, 0)
    144144#  else
     
    151151#endif
    152152
    153 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0)
     153#if RTLNX_VER_MIN(3,20,0)
    154154# define VBOX_HAVE_SKB_VLAN
    155155#else
     
    177177#endif
    178178
    179 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
     179#if RTLNX_VER_MIN(2,6,18)
    180180
    181181/** Indicates that the linux kernel may send us GSO frames. */
     
    196196# define VBOXNETFLT_WITH_GSO_RECV           1
    197197
    198 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18) */
    199 
    200 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     198#endif /* RTLNX_VER_MIN(2,6,18) */
     199
     200#if RTLNX_VER_MIN(2,6,29)
    201201/** This enables or disables handling of GSO frames coming from the wire (GRO). */
    202202# define VBOXNETFLT_WITH_GRO                1
     
    246246
    247247
    248 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12) && defined(LOG_ENABLED)
     248#if RTLNX_VER_MAX(2,6,12) && defined(LOG_ENABLED)
    249249unsigned dev_get_flags(const struct net_device *dev)
    250250{
     
    262262    return flags;
    263263}
    264 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12) */
     264#endif /* RTLNX_VER_MAX(2,6,12) */
    265265
    266266
     
    344344#ifdef VBOXNETFLT_WITH_HOST2WIRE_FILTER
    345345
    346 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
     346# if RTLNX_VER_MAX(2,6,29)
    347347
    348348# include <linux/ethtool.h>
     
    352352# define OVR_XMIT pfnStartXmit
    353353
    354 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
     354# else /* RTLNX_VER_MIN(2,6,29) */
    355355
    356356typedef struct net_device_ops OVR_OPSTYPE;
     
    358358# define OVR_XMIT pOrgOps->ndo_start_xmit
    359359
    360 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
     360# endif /* RTLNX_VER_MIN(2,6,29) */
    361361
    362362/**
     
    379379    /** Pointer to the original ops. */
    380380    OVR_OPSTYPE const              *pOrgOps;
    381 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
     381# if RTLNX_VER_MAX(2,6,29)
    382382    /** Pointer to the original hard_start_xmit function. */
    383383    int (*pfnStartXmit)(struct sk_buff *pSkb, struct net_device *pDev);
    384 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
     384# endif /* RTLNX_VER_MAX(2,6,29) */
    385385    /** Pointer to the net filter instance. */
    386386    PVBOXNETFLTINS                  pVBoxNetFlt;
     
    419419    if (   !VALID_PTR(pOverride)
    420420        || pOverride->u32Magic != VBOXNETDEVICEOPSOVERRIDE_MAGIC
    421 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     421# if RTLNX_VER_MIN(2,6,29)
    422422        || !VALID_PTR(pOverride->pOrgOps)
    423 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
     423# endif /* RTLNX_VER_MIN(2,6,29) */
    424424        )
    425425    {
     
    479479    pOverride->pOrgOps              = pDev->OVR_OPS;
    480480    pOverride->Ops                  = *pDev->OVR_OPS;
    481 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
     481# if RTLNX_VER_MAX(2,6,29)
    482482    pOverride->pfnStartXmit         = pDev->hard_start_xmit;
    483 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
     483# else /* RTLNX_VER_MIN(2,6,29) */
    484484    pOverride->Ops.ndo_start_xmit   = vboxNetFltLinuxStartXmitFilter;
    485 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) */
     485# endif /* RTLNX_VER_MIN(2,6,29) */
    486486    pOverride->u32Magic             = VBOXNETDEVICEOPSOVERRIDE_MAGIC;
    487487    pOverride->cTotal               = 0;
     
    491491    RTSpinlockAcquire(pThis->hSpinlock); /* (this isn't necessary, but so what) */
    492492    ASMAtomicWritePtr((void * volatile *)&pDev->OVR_OPS, pOverride);
    493 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
     493# if RTLNX_VER_MAX(2,6,29)
    494494    ASMAtomicXchgPtr((void * volatile *)&pDev->hard_start_xmit, vboxNetFltLinuxStartXmitFilter);
    495 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
     495# endif /* RTLNX_VER_MAX(2,6,29) */
    496496    RTSpinlockRelease(pThis->hSpinlock);
    497497}
     
    519519           )
    520520        {
    521 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
     521# if RTLNX_VER_MAX(2,6,29)
    522522            ASMAtomicWritePtr((void * volatile *)&pDev->hard_start_xmit, pOverride->pfnStartXmit);
    523 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) */
     523# endif /* RTLNX_VER_MAX(2,6,29) */
    524524            ASMAtomicWritePtr((void const * volatile *)&pDev->OVR_OPS, pOverride->pOrgOps);
    525525            ASMAtomicWriteU32(&pOverride->u32Magic, 0);
     
    566566            Log(("vboxNetFltLinuxRetainNetDev: Device %p(%s) retained. ref=%d\n",
    567567                 pDev, pDev->name,
    568 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
     568#if RTLNX_VER_MIN(2,6,37)
    569569                 netdev_refcnt_read(pDev)
    570570#else
     
    602602        Log(("vboxNetFltLinuxReleaseNetDev: Device %p(%s) released. ref=%d\n",
    603603             pDev, pDev->name,
    604 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
     604#if RTLNX_VER_MIN(2,6,37)
    605605             netdev_refcnt_read(pDev)
    606606#else
     
    773773        Assert(skb_headlen(pPkt) >= pSG->GsoCtx.cbHdrsTotal);
    774774        pPkt->ip_summed  = CHECKSUM_PARTIAL;
    775 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
     775# if RTLNX_VER_MIN(2,6,22)
    776776        pPkt->csum_start = skb_headroom(pPkt) + pSG->GsoCtx.offHdr2;
    777777        if (fGsoType & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))
     
    817817DECLINLINE(unsigned) vboxNetFltLinuxGetChecksumStartOffset(struct sk_buff *pBuf)
    818818{
    819 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 21)
     819#if RTLNX_VER_MIN(2,6,38)
     820    return skb_checksum_start_offset(pBuf);
     821#elif RTLNX_VER_MIN(2,6,22)
     822    return pBuf->csum_start - skb_headroom(pBuf);
     823#else
    820824    unsigned char *pTransportHdr = pBuf->h.raw;
    821 #  if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18)
     825# if RTLNX_VER_MAX(2,6,19)
    822826    /*
    823827     * Try to work around the problem with CentOS 4.7 and 5.2 (2.6.9
     
    828832    if (pBuf->h.raw == pBuf->nh.raw && pBuf->protocol == htons(ETH_P_IP))
    829833        pTransportHdr = pBuf->nh.raw + pBuf->nh.iph->ihl * 4;
    830 #  endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18) */
     834# endif
    831835    return pTransportHdr - pBuf->data;
    832 # else /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 21) */
    833 #  if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 38)
    834     return pBuf->csum_start - skb_headroom(pBuf);
    835 #  else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38) */
    836     return skb_checksum_start_offset(pBuf);
    837 #  endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38) */
    838 # endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 21) */
     836#endif
    839837}
    840838
     
    867865    unsigned cbProduced = 0;
    868866
    869 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     867# if RTLNX_VER_MIN(2,6,27)
    870868    /* Restore VLAN tag stripped by host hardware */
    871869    if (vlan_tx_tag_present(pBuf))
     
    882880        cbProduced += VLAN_ETH_HLEN;
    883881    }
    884 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
     882# endif /* RTLNX_VER_MIN(2,6,27) */
    885883
    886884    if (pBuf->ip_summed == CHECKSUM_PARTIAL && pBuf->pkt_type == PACKET_OUTGOING)
     
    931929    {
    932930        skb_frag_t *pFrag = &skb_shinfo(pBuf)->frags[i];
    933 # if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) || defined(OPENSUSE_152)
     931# if RTLNX_VER_MIN(5,4,0) || defined(OPENSUSE_152)
    934932        pSG->aSegs[iSeg].cb = pFrag->bv_len;
    935933        pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->bv_offset;
     
    952950        {
    953951            skb_frag_t *pFrag = &skb_shinfo(pFragBuf)->frags[i];
    954 # if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) || defined(OPENSUSE_152)
     952# if RTLNX_VER_MIN(5,4,0) || defined(OPENSUSE_152)
    955953            pSG->aSegs[iSeg].cb = pFrag->bv_len;
    956954            pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->bv_offset;
     
    10271025 * @returns 0 or EJUSTRETURN - this is probably copy & pastry and thus wrong.
    10281026 */
    1029 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)
     1027#if RTLNX_VER_MIN(2,6,14)
    10301028static int vboxNetFltLinuxPacketHandler(struct sk_buff *pBuf,
    10311029                                        struct net_device *pSkbDev,
     
    10421040    LogFlow(("vboxNetFltLinuxPacketHandler: pBuf=%p pSkbDev=%p pPacketType=%p\n",
    10431041             pBuf, pSkbDev, pPacketType));
    1044 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
     1042#if RTLNX_VER_MIN(2,6,18)
    10451043    Log3(("vboxNetFltLinuxPacketHandler: skb len=%u data_len=%u truesize=%u next=%p nr_frags=%u gso_size=%u gso_seqs=%u gso_type=%x frag_list=%p pkt_type=%x\n",
    10461044          pBuf->len, pBuf->data_len, pBuf->truesize, pBuf->next, skb_shinfo(pBuf)->nr_frags, skb_shinfo(pBuf)->gso_size, skb_shinfo(pBuf)->gso_segs, skb_shinfo(pBuf)->gso_type, skb_shinfo(pBuf)->frag_list, pBuf->pkt_type));
    1047 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
     1045# if RTLNX_VER_MIN(2,6,22)
    10481046    Log6(("vboxNetFltLinuxPacketHandler: packet dump follows:\n%.*Rhxd\n", pBuf->len-pBuf->data_len, skb_mac_header(pBuf)));
    10491047# endif
     
    11021100        /* Somehow skb_copy ignores mac_len */
    11031101        pBuf->mac_len = uMacLen;
    1104 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     1102# if RTLNX_VER_MIN(2,6,27)
    11051103        /* Restore VLAN tag stripped by host hardware */
    11061104        if (vlan_tx_tag_present(pBuf) && skb_headroom(pBuf) >= VLAN_ETH_HLEN)
     
    11141112            pBuf->mac_len      += VLAN_HLEN;
    11151113        }
    1116 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
    1117 
    1118 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
     1114# endif /* RTLNX_VER_MIN(2,6,27) */
     1115
     1116# if RTLNX_VER_MIN(2,6,18)
    11191117        Log3(("vboxNetFltLinuxPacketHandler: skb copy len=%u data_len=%u truesize=%u next=%p nr_frags=%u gso_size=%u gso_seqs=%u gso_type=%x frag_list=%p pkt_type=%x\n",
    11201118              pBuf->len, pBuf->data_len, pBuf->truesize, pBuf->next, skb_shinfo(pBuf)->nr_frags, skb_shinfo(pBuf)->gso_size, skb_shinfo(pBuf)->gso_segs, skb_shinfo(pBuf)->gso_type, skb_shinfo(pBuf)->frag_list, pBuf->pkt_type));
    1121 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
     1119#  if RTLNX_VER_MIN(2,6,22)
    11221120        Log6(("vboxNetFltLinuxPacketHandler: packet dump follows:\n%.*Rhxd\n", pBuf->len-pBuf->data_len, skb_mac_header(pBuf)));
    1123 #  endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22) */
    1124 # else /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18) */
     1121#  endif /* RTLNX_VER_MIN(2,6,22) */
     1122# else /* RTLNX_VER_MAX(2,6,18) */
    11251123        Log3(("vboxNetFltLinuxPacketHandler: skb copy len=%u data_len=%u truesize=%u next=%p nr_frags=%u tso_size=%u tso_seqs=%u frag_list=%p pkt_type=%x\n",
    11261124              pBuf->len, pBuf->data_len, pBuf->truesize, pBuf->next, skb_shinfo(pBuf)->nr_frags, skb_shinfo(pBuf)->tso_size, skb_shinfo(pBuf)->tso_segs, skb_shinfo(pBuf)->frag_list, pBuf->pkt_type));
    1127 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18) */
     1125# endif /* RTLNX_VER_MAX(2,6,18) */
    11281126    }
    11291127#endif /* !VBOXNETFLT_SG_SUPPORT */
     
    11621160        *pcbTemp = vboxNetFltLinuxGetChecksumStartOffset(pBuf) + VBOX_SKB_CSUM_OFFSET(pBuf) + sizeof(uint16_t);
    11631161    }
    1164 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     1162# if RTLNX_VER_MIN(2,6,27)
    11651163    if (vlan_tx_tag_present(pBuf))
    11661164    {
     
    11701168            *pcbTemp = VLAN_ETH_HLEN;
    11711169    }
    1172 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
     1170# endif /* RTLNX_VER_MIN(2,6,27) */
    11731171    if (*pcbTemp)
    11741172        ++cSegs;
     
    15541552             * skb_gso_segment does the following. Do we need to do it as well?
    15551553             */
    1556 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
     1554# if RTLNX_VER_MIN(2,6,22)
    15571555            skb_reset_mac_header(pBuf);
    15581556            pBuf->mac_len = pBuf->network_header - pBuf->mac_header;
     
    16041602        if (pBuf->ip_summed == CHECKSUM_PARTIAL && pBuf->pkt_type == PACKET_OUTGOING)
    16051603        {
    1606 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18)
     1604# if RTLNX_VER_MIN(2,6,19)
     1605            int rc = VBOX_SKB_CHECKSUM_HELP(pBuf);
     1606# else
    16071607            /*
    16081608             * Try to work around the problem with CentOS 4.7 and 5.2 (2.6.9
     
    16141614            if (pBuf->h.raw == pBuf->nh.raw && pBuf->protocol == htons(ETH_P_IP))
    16151615                pBuf->h.raw = pBuf->nh.raw + pBuf->nh.iph->ihl * 4;
    1616 #endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18) */
    16171616            int rc = VBOX_SKB_CHECKSUM_HELP(pBuf);
    1618 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18)
    16191617            /* Restore the original (wrong) pointer. */
    16201618            pBuf->h.raw = tmp;
    1621 #endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18) */
    1622             if (rc) {
     1619# endif
     1620            if (rc)
     1621            {
    16231622                LogRel(("VBoxNetFlt: Failed to compute checksum, dropping the packet.\n"));
    16241623                return;
     
    16741673 * @param   pWork               The work queue.
    16751674 */
    1676 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     1675# if RTLNX_VER_MIN(2,6,20)
    16771676static void vboxNetFltLinuxXmitTask(struct work_struct *pWork)
    16781677# else
     
    17911790            return true;
    17921791
    1793 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) /* TAP started doing carrier */
     1792#if RTLNX_VER_MIN(2,6,36) /* TAP started doing carrier */
    17941793        return !strncmp(Info.driver,   "tun", 4)
    17951794            && !strncmp(Info.bus_info, "tap", 4);
     
    18001799}
    18011800
    1802 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)
     1801#if RTLNX_VER_MAX(2,6,18)
    18031802DECLINLINE(void) netif_tx_lock_bh(struct net_device *pDev)
    18041803{
     
    18531852    Log(("vboxNetFltLinuxAttachToInterface: Device %p(%s) retained. ref=%d\n",
    18541853          pDev, pDev->name,
    1855 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
     1854#if RTLNX_VER_MIN(2,6,37)
    18561855          netdev_refcnt_read(pDev)
    18571856#else
     
    19501949        Log(("vboxNetFltLinuxUnregisterDevice: Device %p(%s) released. ref=%d\n",
    19511950             pDev, pDev->name,
    1952 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
     1951#if RTLNX_VER_MIN(2,6,37)
    19531952             netdev_refcnt_read(pDev)
    19541953#else
     
    20612060    if (ulEventType == NETDEV_REGISTER)
    20622061    {
    2063 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) /* cgroups/namespaces introduced */
    2064 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
     2062#if RTLNX_VER_MIN(2,6,24) /* cgroups/namespaces introduced */
     2063# if RTLNX_VER_MIN(2,6,26)
    20652064#  define VBOX_DEV_NET(dev)             dev_net(dev)
    20662065#  define VBOX_NET_EQ(n1, n2)           net_eq((n1), (n2))
     
    21332132     * IPv4
    21342133     */
    2135 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 14)
     2134#if RTLNX_VER_MIN(2,6,14)
    21362135    in_dev = __in_dev_get_rtnl(dev);
    21372136#else
     
    21682167
    21692168        read_lock_bh(&in6_dev->lock);
    2170 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
     2169#if RTLNX_VER_MIN(2,6,35)
    21712170        list_for_each_entry(ifa, &in6_dev->addr_list, if_list)
    21722171#else
     
    24722471        Log(("vboxNetFltOsDeleteInstance: Device %p(%s) released. ref=%d\n",
    24732472             pDev, pDev->name,
    2474 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
     2473#if RTLNX_VER_MIN(2,6,37)
    24752474             netdev_refcnt_read(pDev)
    24762475#else
     
    25742573#ifndef VBOXNETFLT_LINUX_NO_XMIT_QUEUE
    25752574    skb_queue_head_init(&pThis->u.s.XmitQueue);
    2576 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     2575# if RTLNX_VER_MIN(2,6,20)
    25772576    INIT_WORK(&pThis->u.s.XmitTask, vboxNetFltLinuxXmitTask);
    25782577# else
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/files_vboxnetflt

    r82968 r85698  
    6565    ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \
    6666    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
     67    ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \
    6768    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
    6869    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
  • trunk/src/VBox/HostDrivers/VBoxPci/VBoxPciInternal.h

    r82968 r85698  
    3838#ifdef RT_OS_LINUX
    3939
    40 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) && defined(CONFIG_IOMMU_API)
     40#if RTLNX_VER_MIN(2,6,35) && defined(CONFIG_IOMMU_API)
    4141# define VBOX_WITH_IOMMU
    4242#endif
  • trunk/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c

    r83471 r85698  
    4848# include <linux/intel-iommu.h>
    4949# include <linux/pci.h>
    50 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0) && \
    51      (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 41) || LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0))
     50# if RTLNX_VER_MAX(3,1,0) && \
     51     (RTLNX_VER_MAX(2,6,41) || RTLNX_VER_MIN(3,0,0))
    5252#  include <asm/amd_iommu.h>
    5353# else
    5454#  include <linux/amd-iommu.h>
    5555# endif
    56 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
     56# if RTLNX_VER_MAX(3,2,0)
    5757#  define IOMMU_PRESENT()      iommu_found()
    5858#  define IOMMU_DOMAIN_ALLOC() iommu_domain_alloc()
     
    8787
    8888
    89 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     89#if RTLNX_VER_MIN(2,6,20)
    9090# define PCI_DEV_GET(v,d,p)            pci_get_device(v,d,p)
    9191# define PCI_DEV_PUT(x)                pci_dev_put(x)
    92 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
     92#if RTLNX_VER_MIN(4,17,0)
    9393/* assume the domain number to be zero - exactly the same assumption of
    9494 * pci_get_bus_and_slot()
     
    165165    if (request_module(PCI_STUB_MODULE) == 0)
    166166    {
    167 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     167# if RTLNX_VER_MIN(2,6,30)
    168168        /* find_module() is static before Linux 2.6.30 */
    169169        mutex_lock(&module_mutex);
     
    320320    if (RT_LIKELY(pIns->pPciDev))
    321321    {
    322 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     322#if RTLNX_VER_MIN(2,6,28)
    323323        if (pci_reset_function(pIns->pPciDev))
    324324        {
     
    374374    fs_save = get_fs();
    375375    set_fs(KERNEL_DS);
    376 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
     376#if RTLNX_VER_MIN(4,14,0)
    377377    ret = kernel_write(file, data, size, &offset);
    378378#else
     
    448448        int                iCmdLen;
    449449        const int          cMaxBuf = 128;
    450 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     450#if RTLNX_VER_MIN(2,6,29)
    451451        const struct cred *pOldCreds;
    452452        struct cred       *pNewCreds;
     
    469469
    470470        /* Somewhat ugly hack - override current credentials */
    471 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     471#if RTLNX_VER_MIN(2,6,29)
    472472        pNewCreds = prepare_creds();
    473473        if (!pNewCreds)
    474474                goto done;
    475475
    476 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     476# if RTLNX_VER_MIN(3,5,0)
    477477        pNewCreds->fsuid = GLOBAL_ROOT_UID;
    478478# else
     
    533533            printk(KERN_DEBUG "vboxpci: cannot open %s\n", szFileBuf);
    534534
    535 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     535#if RTLNX_VER_MIN(2,6,29)
    536536        revert_creds(pOldCreds);
    537537        put_cred(pNewCreds);
     
    560560        int                iCmdLen;
    561561        const int          cMaxBuf = 128;
    562 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     562#if RTLNX_VER_MIN(2,6,29)
    563563        const struct cred *pOldCreds;
    564564        struct cred       *pNewCreds;
     
    586586
    587587        /* Somewhat ugly hack - override current credentials */
    588 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     588#if RTLNX_VER_MIN(2,6,29)
    589589        pNewCreds = prepare_creds();
    590590        if (!pNewCreds)
    591591            goto done;
    592592
    593 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     593# if RTLNX_VER_MIN(3,5,0)
    594594        pNewCreds->fsuid = GLOBAL_ROOT_UID;
    595595# else
     
    627627            printk(KERN_DEBUG "vboxpci: cannot open %s\n", szFileBuf);
    628628
    629 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     629#if RTLNX_VER_MIN(2,6,29)
    630630        revert_creds(pOldCreds);
    631631        put_cred(pNewCreds);
     
    670670                vbpci_printk(KERN_DEBUG, pPciDev, "%s\n", __func__);
    671671
    672 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 1)
     672#if RTLNX_VER_MIN(2,6,1)
    673673                if (pci_enable_msi(pPciDev) == 0)
    674674                    pIns->fMsiUsed = true;
     
    717717        vboxPciLinuxDevUnregisterWithIommu(pIns);
    718718
    719 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 1)
     719#if RTLNX_VER_MIN(2,6,1)
    720720        if (pIns->fMsiUsed)
    721721            pci_disable_msi(pPciDev);
     
    843843        if (!rcLnx)
    844844        {
    845 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
     845#if RTLNX_VER_MIN(2,6,25)
    846846            /*
    847847             * ioremap() defaults to no caching since the 2.6 kernels.
     
    859859            else
    860860            {
    861 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
     861#if RTLNX_VER_MIN(2,6,25)
    862862                vbpci_printk(KERN_DEBUG, pPciDev, "ioremap() failed\n");
    863863#else
     
    956956 * @param   pRegs           Register set. Removed in 2.6.19.
    957957 */
    958 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && !defined(DOXYGEN_RUNNING)
     958#if RTLNX_VER_MIN(2,6,19) && !defined(DOXYGEN_RUNNING)
    959959static irqreturn_t vboxPciOsIrqHandler(int iIrq, void *pvDevId)
    960960#else
     
    992992#ifdef VBOX_WITH_SHARED_PCI_INTERRUPTS
    993993                     /* Allow interrupts sharing. */
    994 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     994# if RTLNX_VER_MIN(2,6,20)
    995995                     IRQF_SHARED,
    996996# else
     
    10021002                     /* We don't allow interrupts sharing */
    10031003                     /* XXX overhaul */
    1004 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
     1004# if RTLNX_VER_MIN(2,6,20) && RTLNX_VER_MAX(4,1,0)
    10051005                     IRQF_DISABLED, /* keep irqs disabled when calling the action handler */
    10061006# else
  • trunk/src/VBox/HostDrivers/VBoxPci/linux/files_vboxpci

    r82968 r85698  
    6464    ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \
    6565    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
     66    ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \
    6667    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
    6768    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
  • trunk/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c

    r85505 r85698  
    3939
    4040#if (defined(RT_ARCH_AMD64) || defined(DOXYGEN_RUNNING)) && !defined(RTMEMALLOC_EXEC_HEAP)
    41 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
     41# if RTLNX_VER_MIN(2,6,23) && RTLNX_VER_MAX(5,8,0)
    4242/**
    4343 * Starting with 2.6.23 we can use __get_vm_area and map_vm_area to allocate
     
    197197         * in the free function, if nothing else...
    198198         */
    199 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
     199# if RTLNX_VER_MAX(3,17,0)
    200200        struct page **papPagesIterator = papPages;
    201201# endif
     
    203203        pVmArea->pages    = papPages;
    204204        if (!map_vm_area(pVmArea, PAGE_KERNEL_EXEC,
    205 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
     205# if RTLNX_VER_MAX(3,17,0)
    206206                         &papPagesIterator
    207207# else
     
    216216        }
    217217        /* bail out */
    218 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
     218# if RTLNX_VER_MAX(3,17,0)
    219219        pVmArea->nr_pages = papPagesIterator - papPages;
    220220# endif
  • trunk/src/VBox/Runtime/r0drv/linux/initterm-r0drv-linux.c

    r82968 r85698  
    4040*********************************************************************************************************************************/
    4141/** The IPRT work queue. */
    42 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
     42#if RTLNX_VER_MIN(2,5,41)
    4343static struct workqueue_struct *g_prtR0LnxWorkQueue;
    4444#else
     
    5858    IPRT_LINUX_SAVE_EFL_AC();
    5959
    60 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
    61 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     60#if RTLNX_VER_MIN(2,5,41)
     61# if RTLNX_VER_MIN(2,6,20)
    6262    INIT_WORK(pWork, pfnWorker);
    6363# else
     
    8484    IPRT_LINUX_SAVE_EFL_AC();
    8585
    86 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
     86#if RTLNX_VER_MIN(2,5,41)
    8787    flush_workqueue(g_prtR0LnxWorkQueue);
    8888#else
     
    9999    IPRT_LINUX_SAVE_EFL_AC();
    100100
    101 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
    102  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
     101#if RTLNX_VER_MIN(2,5,41)
     102 #if RTLNX_VER_MIN(2,6,13)
    103103    g_prtR0LnxWorkQueue = create_workqueue("iprt-VBoxWQueue");
    104104 #else
     
    119119
    120120    rtR0LnxWorkqueueFlush();
    121 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
     121#if RTLNX_VER_MIN(2,5,41)
    122122    destroy_workqueue(g_prtR0LnxWorkQueue);
    123123    g_prtR0LnxWorkQueue = NULL;
  • trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c

    r85516 r85698  
    5757 * This is a must for 5.8+, but we enable it all the way back to 3.2.x for
    5858 * better W^R compliance (fExecutable flag). */
    59 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0) || defined(DOXYGEN_RUNNING)
     59#if RTLNX_VER_MIN(3,2,0) || defined(DOXYGEN_RUNNING)
    6060# define IPRT_USE_ALLOC_VM_AREA_FOR_EXEC
    6161#endif
     
    6666 * It should be safe to use vm_insert_page() older kernels as well.
    6767 */
    68 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 23)
     68#if RTLNX_VER_MIN(2,6,23)
    6969# define VBOX_USE_INSERT_PAGE
    7070#endif
    7171#if    defined(CONFIG_X86_PAE) \
    7272    && (   defined(HAVE_26_STYLE_REMAP_PAGE_RANGE) \
    73         || (   LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) \
    74             && LINUX_VERSION_CODE <  KERNEL_VERSION(2, 6, 11)))
     73        || RTLNX_VER_RANGE(2,6,0,  2,6,11) )
    7574# define VBOX_USE_PAE_HACK
    7675#endif
    7776
    7877/* gfp_t was introduced in 2.6.14, define it for earlier. */
    79 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
     78#if RTLNX_VER_MAX(2,6,14)
    8079# define gfp_t  unsigned
    8180#endif
     
    8483 * Wrappers around mmap_lock/mmap_sem difference.
    8584 */
    86 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
     85#if RTLNX_VER_MIN(5,8,0)
    8786# define LNX_MM_DOWN_READ(a_pMm)    down_read(&(a_pMm)->mmap_lock)
    8887# define LNX_MM_UP_READ(a_pMm)        up_read(&(a_pMm)->mmap_lock)
     
    252251    if (R3PtrFixed != (RTR3PTR)-1)
    253252    {
    254 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     253#if RTLNX_VER_MIN(3,5,0)
    255254        ulAddr = vm_mmap(NULL, R3PtrFixed, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, 0);
    256255#else
     
    262261    else
    263262    {
    264 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     263#if RTLNX_VER_MIN(3,5,0)
    265264        ulAddr = vm_mmap(NULL, 0, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS, 0);
    266265#else
     
    298297static void rtR0MemObjLinuxDoMunmap(void *pv, size_t cb, struct task_struct *pTask)
    299298{
    300 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     299#if RTLNX_VER_MIN(3,5,0)
    301300    Assert(pTask == current); RT_NOREF_PV(pTask);
    302301    vm_munmap((unsigned long)pv, cb);
     
    359358     * For small allocations we'll try contiguous first and then fall back on page by page.
    360359     */
    361 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
     360#if RTLNX_VER_MIN(2,4,22)
    362361    if (    fContiguous
    363362        ||  cb <= PAGE_SIZE * 2)
     
    418417    pMemLnx->fExecutable = fExecutable;
    419418
    420 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
     419#if RTLNX_VER_MAX(4,5,0)
    421420    /*
    422421     * Reserve the pages.
     
    475474        while (iPage-- > 0)
    476475        {
    477 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
     476#if RTLNX_VER_MAX(4,5,0)
    478477            /* See SetPageReserved() in rtR0MemObjLinuxAllocPages() */
    479478            ClearPageReserved(pMemLnx->apPages[iPage]);
    480479#endif
    481 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 22)
     480#if RTLNX_VER_MAX(2,4,22)
    482481            if (pMemLnx->fExecutable)
    483482                MY_SET_PAGES_NOEXEC(pMemLnx->apPages[iPage], 1);
     
    488487         * Free the pages.
    489488         */
    490 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
     489#if RTLNX_VER_MIN(2,4,22)
    491490        if (!pMemLnx->fContiguous)
    492491        {
     
    545544         * Use vmap - 2.4.22 and later.
    546545         */
    547 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
     546#if RTLNX_VER_MIN(2,4,22)
    548547        pgprot_t fPg;
    549548        pgprot_val(fPg) = _PAGE_PRESENT | _PAGE_RW;
     
    620619static void rtR0MemObjLinuxVUnmap(PRTR0MEMOBJLNX pMemLnx)
    621620{
    622 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
     621#if RTLNX_VER_MIN(2,4,22)
    623622# ifdef IPRT_USE_ALLOC_VM_AREA_FOR_EXEC
    624623    if (pMemLnx->pArea)
     
    683682                    if (!PageReserved(pMemLnx->apPages[iPage]))
    684683                        SetPageDirty(pMemLnx->apPages[iPage]);
    685 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
     684#if RTLNX_VER_MIN(4,6,0)
    686685                    put_page(pMemLnx->apPages[iPage]);
    687686#else
     
    746745    int rc;
    747746
    748 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
     747#if RTLNX_VER_MIN(2,4,22)
    749748    rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, PAGE_SIZE, GFP_HIGHUSER,
    750749                                   false /* non-contiguous */, fExecutable, VERR_NO_MEMORY);
     
    995994    {
    996995        pgd_t       Global;
    997 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
     996#if RTLNX_VER_MIN(4,12,0)
    998997        p4d_t       Four;
    999998#endif
    1000 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
     999#if RTLNX_VER_MIN(2,6,11)
    10011000        pud_t       Upper;
    10021001#endif
     
    10131012    if (RT_UNLIKELY(pgd_none(u.Global)))
    10141013        return NULL;
    1015 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
    1016 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
     1014#if RTLNX_VER_MIN(2,6,11)
     1015# if RTLNX_VER_MIN(4,12,0)
    10171016    u.Four  = *p4d_offset(&u.Global, ulAddr);
    10181017    if (RT_UNLIKELY(p4d_none(u.Four)))
     
    10331032    if (RT_UNLIKELY(pud_none(u.Upper)))
    10341033        return NULL;
    1035 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
     1034# if RTLNX_VER_MIN(2,6,25)
    10361035    if (pud_large(u.Upper))
    10371036    {
     
    10491048    if (RT_UNLIKELY(pmd_none(u.Middle)))
    10501049        return NULL;
    1051 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     1050#if RTLNX_VER_MIN(2,6,0)
    10521051    if (pmd_large(u.Middle))
    10531052    {
     
    10601059#endif
    10611060
    1062 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 5) || defined(pte_offset_map) /* As usual, RHEL 3 had pte_offset_map earlier. */
     1061#if RTLNX_VER_MIN(2,5,5) || defined(pte_offset_map) /* As usual, RHEL 3 had pte_offset_map earlier. */
    10631062    pEntry = pte_offset_map(&u.Middle, ulAddr);
    10641063#else
     
    10681067        return NULL;
    10691068    u.Entry = *pEntry;
    1070 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 5) || defined(pte_offset_map)
     1069#if RTLNX_VER_MIN(2,5,5) || defined(pte_offset_map)
    10711070    pte_unmap(pEntry);
    10721071#endif
     
    11201119
    11211120/* openSUSE Leap 42.3 detection :-/ */
    1122 #if    LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0) \
    1123     && LINUX_VERSION_CODE <  KERNEL_VERSION(4, 6, 0) \
    1124     && defined(FAULT_FLAG_REMOTE)
     1121#if RTLNX_VER_RANGE(4,4,0,  4,6,0) && defined(FAULT_FLAG_REMOTE)
    11251122# define GET_USER_PAGES_API     KERNEL_VERSION(4, 10, 0) /* no typo! */
    11261123#else
     
    11341131    struct task_struct *pTask = rtR0ProcessToLinuxTask(R0Process);
    11351132    struct vm_area_struct **papVMAs;
    1136     PRTR0MEMOBJLNX pMemLnx;
     1133    PRTR0MEMOBJLNX  pMemLnx;
    11371134    int             rc      = VERR_NO_MEMORY;
    11381135    int  const      fWrite  = fAccess & RTMEM_PROT_WRITE ? 1 : 0;
     
    12091206                                cPages,                 /* How many pages. */
    12101207/* The get_user_pages API change was back-ported to 4.4.168. */
    1211 # if    LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 168) \
    1212       && LINUX_VERSION_CODE <  KERNEL_VERSION(4, 5, 0)
     1208# if RTLNX_VER_RANGE(4,4,168,  4,5,0)
    12131209                                fWrite ? FOLL_WRITE |   /* Write to memory. */
    12141210                                         FOLL_FORCE     /* force write access. */
     
    12651261            if (!PageReserved(pMemLnx->apPages[rc]))
    12661262                SetPageDirty(pMemLnx->apPages[rc]);
    1267 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
     1263#if RTLNX_VER_MIN(4,6,0)
    12681264            put_page(pMemLnx->apPages[rc]);
    12691265#else
     
    13751371DECLHIDDEN(int) rtR0MemObjNativeReserveKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment)
    13761372{
    1377 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
     1373#if RTLNX_VER_MIN(2,4,22)
    13781374    IPRT_LINUX_SAVE_EFL_AC();
    13791375    const size_t cPages = cb >> PAGE_SHIFT;
     
    15001496        if (pMemLnxToMap->cPages)
    15011497        {
    1502 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
     1498#if RTLNX_VER_MIN(2,4,22)
    15031499            /*
    15041500             * Use vmap - 2.4.22 and later.
     
    15451541             */
    15461542            Assert(pMemLnxToMap->Core.enmType == RTR0MEMOBJTYPE_PHYS && !pMemLnxToMap->Core.u.Phys.fAllocated);
    1547 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
     1543#if RTLNX_VER_MIN(2,6,25)
    15481544            /*
    15491545             * ioremap() defaults to no caching since the 2.6 kernels.
     
    16951691                for (iPage = offSub >> PAGE_SHIFT; iPage < cPages; iPage++, ulAddrCur += PAGE_SIZE)
    16961692                {
    1697 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 11)
     1693#if RTLNX_VER_MAX(2,6,11)
    16981694                    RTHCPHYS Phys = page_to_phys(pMemLnxToMap->apPages[iPage]);
    16991695#endif
    1700 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
     1696#if RTLNX_VER_MIN(2,6,0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
    17011697                    struct vm_area_struct *vma = find_vma(pTask->mm, ulAddrCur); /* this is probably the same for all the pages... */
    17021698                    AssertBreakStmt(vma, rc = VERR_INTERNAL_ERROR);
    17031699#endif
    1704 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) && defined(RT_ARCH_X86)
     1700#if RTLNX_VER_MAX(2,6,0) && defined(RT_ARCH_X86)
    17051701                    /* remap_page_range() limitation on x86 */
    17061702                    AssertBreakStmt(Phys < _4G, rc = VERR_NO_MEMORY);
    17071703#endif
    17081704
    1709 #if   defined(VBOX_USE_INSERT_PAGE) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
     1705#if   defined(VBOX_USE_INSERT_PAGE) && RTLNX_VER_MIN(2,6,22)
    17101706                    rc = vm_insert_page(vma, ulAddrCur, pMemLnxToMap->apPages[iPage]);
    17111707                    /* Thes flags help making 100% sure some bad stuff wont happen (swap, core, ++).
    17121708                     * See remap_pfn_range() in mm/memory.c */
    1713 #if    LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
     1709#if    RTLNX_VER_MIN(3,7,0)
    17141710                    vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
    17151711#else
    17161712                    vma->vm_flags |= VM_RESERVED;
    17171713#endif
    1718 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
     1714#elif RTLNX_VER_MIN(2,6,11)
    17191715                    rc = remap_pfn_range(vma, ulAddrCur, page_to_pfn(pMemLnxToMap->apPages[iPage]), PAGE_SIZE, fPg);
    17201716#elif defined(VBOX_USE_PAE_HACK)
     
    17221718                    if (!rc)
    17231719                        rc = rtR0MemObjLinuxFixPte(pTask->mm, ulAddrCur, Phys);
    1724 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
     1720#elif RTLNX_VER_MIN(2,6,0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
    17251721                    rc = remap_page_range(vma, ulAddrCur, Phys, PAGE_SIZE, fPg);
    17261722#else /* 2.4 */
     
    17501746                    for (iPage = offSub >> PAGE_SHIFT; iPage < cPages; iPage++, ulAddrCur += PAGE_SIZE, Phys += PAGE_SIZE)
    17511747                    {
    1752 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
     1748#if RTLNX_VER_MIN(2,6,0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
    17531749                        struct vm_area_struct *vma = find_vma(pTask->mm, ulAddrCur); /* this is probably the same for all the pages... */
    17541750                        AssertBreakStmt(vma, rc = VERR_INTERNAL_ERROR);
    17551751#endif
    1756 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) && defined(RT_ARCH_X86)
     1752#if RTLNX_VER_MAX(2,6,0) && defined(RT_ARCH_X86)
    17571753                        /* remap_page_range() limitation on x86 */
    17581754                        AssertBreakStmt(Phys < _4G, rc = VERR_NO_MEMORY);
    17591755#endif
    17601756
    1761 #if   LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
     1757#if   RTLNX_VER_MIN(2,6,11)
    17621758                        rc = remap_pfn_range(vma, ulAddrCur, Phys, PAGE_SIZE, fPg);
    17631759#elif defined(VBOX_USE_PAE_HACK)
     
    17651761                        if (!rc)
    17661762                            rc = rtR0MemObjLinuxFixPte(pTask->mm, ulAddrCur, Phys);
    1767 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
     1763#elif RTLNX_VER_MIN(2,6,0) || defined(HAVE_26_STYLE_REMAP_PAGE_RANGE)
    17681764                        rc = remap_page_range(vma, ulAddrCur, Phys, PAGE_SIZE, fPg);
    17691765#else /* 2.4 */
     
    17801776
    17811777#ifdef CONFIG_NUMA_BALANCING
    1782 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
     1778# if RTLNX_VER_MAX(3,13,0)
    17831779#  ifdef RHEL_RELEASE_CODE
    17841780#   if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(7, 0)
  • trunk/src/VBox/Runtime/r0drv/linux/memuserkernel-r0drv-linux.c

    r82968 r85698  
    6767{
    6868    IPRT_LINUX_SAVE_EFL_AC();
    69 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) || defined(RHEL_81)
     69#if RTLNX_VER_MIN(5,0,0) || defined(RHEL_81)
    7070    bool fRc = access_ok((void *)R3Ptr, 1);
    7171#else
     
    8787#else
    8888# error "PORT ME"
    89 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) || defined(RHEL_81)
     89#if RTLNX_VER_MIN(5,0,0) || defined(RHEL_81)
    9090    return !access_ok(pv, 1);
    9191#else
    9292    return !access_ok(VERIFY_READ, pv, 1);
    93 #endif /* LINUX_VERSION_CODE */
     93#endif
    9494#endif
    9595}
     
    113113static int rtR0MemKernelCopyLnxWorker(void *pvDst, void const *pvSrc, size_t cb)
    114114{
    115 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 55)
     115#if RTLNX_VER_MIN(2,5,55)
    116116/* _ASM_EXTABLE was introduced in 2.6.25 from what I can tell. Using #ifndef
    117117   here since it has to be a macro and you never know what someone might have
  • trunk/src/VBox/Runtime/r0drv/linux/mp-r0drv-linux.c

    r85602 r85698  
    4343*   Defined Constants And Macros                                                                                                 *
    4444*********************************************************************************************************************************/
    45 #if defined(nr_cpumask_bits) || LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     45#if defined(nr_cpumask_bits) || RTLNX_VER_MIN(2,6,28)
    4646# define VBOX_NR_CPUMASK_BITS   (nr_cpumask_bits)   /* same as nr_cpu_ids */
    4747#else
     
    9595{
    9696#if defined(CONFIG_SMP)
    97 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 2) || defined(cpu_possible)
     97# if RTLNX_VER_MIN(2,6,2) || defined(cpu_possible)
    9898    return idCpu < VBOX_NR_CPUMASK_BITS && cpu_possible(idCpu);
    9999# else /* < 2.5.29 */
     
    126126{
    127127#ifdef CONFIG_SMP
    128 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 4) || defined(num_possible_cpus)
     128# if RTLNX_VER_MIN(2,6,4) || defined(num_possible_cpus)
    129129    return num_possible_cpus();
    130 # elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
     130# elif RTLNX_VER_MAX(2,5,0)
    131131    return smp_num_cpus;
    132132# else
     
    145145{
    146146#ifdef CONFIG_SMP
    147 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(cpu_online)
     147# if RTLNX_VER_MIN(2,6,0) || defined(cpu_online)
    148148    return idCpu < VBOX_NR_CPUMASK_BITS && cpu_online(idCpu);
    149149# else /* 2.4: */
     
    181181{
    182182#ifdef CONFIG_SMP
    183 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(num_online_cpus)
     183# if RTLNX_VER_MIN(2,6,0) || defined(num_online_cpus)
    184184    return num_online_cpus();
    185185# else
     
    217217#ifdef CONFIG_SMP
    218218
    219 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     219# if RTLNX_VER_MIN(2,6,27)
    220220/**
    221221 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER, does hit
     
    281281    {
    282282        /* Fire the function on all other CPUs without waiting for completion. */
    283 # if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)
     283# if RTLNX_VER_MIN(5,3,0)
    284284        smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* wait */);
    285 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     285# elif RTLNX_VER_MIN(2,6,27)
    286286        int rc = smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* wait */);
    287287        Assert(!rc); NOREF(rc);
     
    337337
    338338    RTThreadPreemptDisable(&PreemptState);
    339 # if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)
     339# if RTLNX_VER_MIN(5,3,0)
    340340    smp_call_function(rtmpLinuxWrapper, &Args, 1 /* wait */);
    341 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     341# elif RTLNX_VER_MIN(2,6,27)
    342342    int rc = smp_call_function(rtmpLinuxWrapper, &Args, 1 /* wait */);
    343343    Assert(rc == 0); NOREF(rc);
     
    357357
    358358
    359 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) && defined(CONFIG_SMP)
     359#if RTLNX_VER_MAX(2,6,27) && defined(CONFIG_SMP)
    360360/**
    361361 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER
     
    385385    int                     rc;
    386386    RTTHREADPREEMPTSTATE    PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER;
    387 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) /* 2.6.28 introduces CONFIG_CPUMASK_OFFSTACK */
     387# if RTLNX_VER_MIN(2,6,28) /* 2.6.28 introduces CONFIG_CPUMASK_OFFSTACK */
    388388    cpumask_var_t           DstCpuMask;
    389 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     389# elif RTLNX_VER_MIN(2,6,27)
    390390    cpumask_t               DstCpuMask;
    391391# endif
     
    397397     * Prepare the CPU mask before we disable preemption.
    398398     */
    399 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     399# if RTLNX_VER_MIN(2,6,30)
    400400    if (!zalloc_cpumask_var(&DstCpuMask, GFP_KERNEL))
    401401        return VERR_NO_MEMORY;
    402402    cpumask_set_cpu(idCpu1, DstCpuMask);
    403403    cpumask_set_cpu(idCpu2, DstCpuMask);
    404 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     404# elif RTLNX_VER_MIN(2,6,28)
    405405    if (!alloc_cpumask_var(&DstCpuMask, GFP_KERNEL))
    406406        return VERR_NO_MEMORY;
     
    408408    cpumask_set_cpu(idCpu1, DstCpuMask);
    409409    cpumask_set_cpu(idCpu2, DstCpuMask);
    410 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     410# elif RTLNX_VER_MIN(2,6,27)
    411411    cpus_clear(DstCpuMask);
    412412    cpu_set(idCpu1, DstCpuMask);
     
    437437        Args.cHits   = 0;
    438438
    439 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     439# if RTLNX_VER_MIN(2,6,28)
    440440        smp_call_function_many(DstCpuMask, rtmpLinuxWrapperPostInc, &Args, !fCallSelf /* wait */);
    441441        rc = 0;
    442 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     442# elif RTLNX_VER_MIN(2,6,27)
    443443        rc = smp_call_function_mask(DstCpuMask, rtmpLinuxWrapperPostInc, &Args, !fCallSelf /* wait */);
    444444# else /* older kernels */
     
    481481
    482482    RTThreadPreemptRestore(&PreemptState);;
    483 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     483# if RTLNX_VER_MIN(2,6,28)
    484484    free_cpumask_var(DstCpuMask);
    485485# endif
     
    502502
    503503
    504 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19) && defined(CONFIG_SMP)
     504#if RTLNX_VER_MAX(2,6,19) && defined(CONFIG_SMP)
    505505/**
    506506 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER
     
    545545        if (RTMpIsCpuOnline(idCpu))
    546546        {
    547 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     547# if RTLNX_VER_MIN(2,6,27)
    548548            rc = smp_call_function_single(idCpu, rtmpLinuxWrapper, &Args, 1 /* wait */);
    549 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     549# elif RTLNX_VER_MIN(2,6,19)
    550550            rc = smp_call_function_single(idCpu, rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */);
    551551# else /* older kernels */
     
    573573
    574574
    575 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && defined(CONFIG_SMP)
     575#if RTLNX_VER_MIN(2,6,19) && defined(CONFIG_SMP)
    576576/**
    577577 * Dummy callback used by RTMpPokeCpu.
     
    588588RTDECL(int) RTMpPokeCpu(RTCPUID idCpu)
    589589{
    590 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     590#if RTLNX_VER_MIN(2,6,19)
    591591    IPRT_LINUX_SAVE_EFL_AC();
    592592    int rc;
     
    596596        {
    597597# ifdef CONFIG_SMP
    598 #  if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     598#  if RTLNX_VER_MIN(2,6,27)
    599599            rc = smp_call_function_single(idCpu, rtmpLinuxPokeCpuCallback, NULL, 0 /* wait */);
    600 #  elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)
     600#  elif RTLNX_VER_MIN(2,6,19)
    601601            rc = smp_call_function_single(idCpu, rtmpLinuxPokeCpuCallback, NULL, 0 /* retry */, 0 /* wait */);
    602602#  else  /* older kernels */
  • trunk/src/VBox/Runtime/r0drv/linux/mpnotification-r0drv-linux.c

    r82968 r85698  
    3838#include "r0drv/mp-r0drv.h"
    3939
    40 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
     40#if RTLNX_VER_MIN(4,10,0)
    4141
    4242static enum cpuhp_state g_rtR0MpOnline;
     
    8686}
    8787
    88 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 71) && defined(CONFIG_SMP)
     88#elif RTLNX_VER_MIN(2,5,71) && defined(CONFIG_SMP)
    8989
    9090static int rtMpNotificationLinuxCallback(struct notifier_block *pNotifierBlock, unsigned long ulNativeEvent, void *pvCpu);
  • trunk/src/VBox/Runtime/r0drv/linux/rtStrFormatKernelAddress-r0drv-linux.c

    r82968 r85698  
    4242                                            signed int cchPrecision, unsigned int fFlags)
    4343{
    44 #if !defined(DEBUG) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
     44#if !defined(DEBUG) && RTLNX_VER_MIN(2,6,38)
    4545    RT_NOREF(cchWidth, cchPrecision);
    4646    /* use the Linux kernel function which is able to handle "%pK" */
  • trunk/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h

    r85690 r85698  
    4949
    5050
    51 /** @def RTLNX_VER_MIN
    52  * Evaluates to true if the linux kernel version is equal or higher to the
    53  * one specfied. */
    54 #define RTLNX_VER_MIN(a_Major, a_Minor, a_Patch) \
    55     (LINUX_VERSION_CODE >= KERNEL_VERSION(a_Major, a_Minor, a_Patch))
    56 /** @def RTLNX_VER_MAX
    57  * Evaluates to true if the linux kernel version is less to the one specfied
    58  * (exclusive). */
    59 #define RTLNX_VER_MAX(a_Major, a_Minor, a_Patch) \
    60     (LINUX_VERSION_CODE <  KERNEL_VERSION(a_Major, a_Minor, a_Patch))
    61 /** @def RTLNX_VER_RANGE
    62  * Evaluates to true if the linux kernel version is equal or higher to the given
    63  * minimum version and less (but not equal) to the maximum version (exclusive). */
    64 #define RTLNX_VER_RANGE(a_MajorMin, a_MinorMin, a_PatchMin,  a_MajorMax, a_MinorMax, a_PatchMax) \
    65     (   LINUX_VERSION_CODE >= KERNEL_VERSION(a_MajorMin, a_MinorMin, a_PatchMin) \
    66      && LINUX_VERSION_CODE <  KERNEL_VERSION(a_MajorMax, a_MinorMax, a_PatchMax) )
    67 
    68 
    69 #include <linux/version.h>
    70 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
     51#include <iprt/linux/version.h>
     52#if RTLNX_VER_MIN(2,6,33)
    7153# include <generated/autoconf.h>
    7254#else
     
    7759
    7860/* We only support 2.4 and 2.6 series kernels */
    79 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 0)
     61#if RTLNX_VER_MAX(2,4,0)
    8062# error Sorry, we do not support 2.3 and earlier kernels.
    8163#endif
    82 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     64#if RTLNX_VER_MIN(2,5,0) && RTLNX_VER_MAX(2,6,0)
    8365# error Sorry, we do not support 2.5 series kernels (might work though).
    8466#endif
     
    8668#if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
    8769# define MODVERSIONS
    88 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 71)
     70# if RTLNX_VER_MAX(2,5,71)
    8971#  include <linux/modversions.h>
    9072# endif
    9173#endif
    9274#ifndef KBUILD_STR
    93 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
     75# if RTLNX_VER_MAX(2,6,16)
    9476#  define KBUILD_STR(s) s
    9577# else
     
    9779# endif
    9880#endif
    99 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
     81# if RTLNX_VER_MIN(3,3,0)
    10082#  include <linux/kconfig.h> /* for macro IS_ENABLED */
    10183# endif
     
    10385#include <linux/spinlock.h>
    10486#include <linux/slab.h>
    105 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     87#if RTLNX_VER_MIN(2,6,27)
    10688# include <linux/semaphore.h>
    10789#else /* older kernels */
     
    10991#endif /* older kernels */
    11092#include <linux/module.h>
    111 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     93#if RTLNX_VER_MIN(2,6,0)
    11294# include <linux/moduleparam.h>
    11395#endif
     
    11597#include <linux/init.h>
    11698#include <linux/fs.h>
    117 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     99#if RTLNX_VER_MIN(2,6,0)
    118100# include <linux/namei.h>
    119101#endif
     
    124106#include <linux/sched.h>
    125107
    126 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 23) && \
    127     LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 31)
    128 #include  <linux/splice.h>
    129 #endif
    130 
    131 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
     108#if RTLNX_VER_RANGE(3,9,23,  3,9,31)
     109# include  <linux/splice.h>
     110#endif
     111
     112#if RTLNX_VER_MIN(3,9,0)
    132113# include <linux/sched/rt.h>
    133114#endif
    134 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     115#if RTLNX_VER_MIN(4,11,0)
    135116# include <linux/sched/signal.h>
    136117# include <linux/sched/types.h>
    137118#endif
    138 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 7)
     119#if RTLNX_VER_MIN(2,6,7)
    139120# include <linux/jiffies.h>
    140121#endif
    141 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
     122#if RTLNX_VER_MIN(2,6,16)
    142123# include <linux/ktime.h>
    143124# include <linux/hrtimer.h>
    144125#endif
    145126#include <linux/wait.h>
    146 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 71)
     127#if RTLNX_VER_MIN(2,5,71)
    147128# include <linux/cpu.h>
    148129# include <linux/notifier.h>
    149130#endif
    150 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
     131#if RTLNX_VER_MIN(5,1,0)
    151132# include <uapi/linux/mman.h>
    152133#endif
     
    171152
    172153/* For thread-context hooks. */
    173 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18) && defined(CONFIG_PREEMPT_NOTIFIERS)
     154#if RTLNX_VER_MIN(2,6,18) && defined(CONFIG_PREEMPT_NOTIFIERS)
    174155# include <linux/preempt.h>
    175156#endif
    176157
    177158/* for workqueue / task queues. */
    178 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
     159#if RTLNX_VER_MIN(2,5,41)
    179160# include <linux/workqueue.h>
    180161#else
     
    182163#endif
    183164
    184 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 4)
     165#if RTLNX_VER_MIN(2,6,4)
    185166# include <linux/kthread.h>
    186167#endif
    187168
    188169/* for cr4_init_shadow() / cpu_tlbstate. */
    189 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0)
     170#if RTLNX_VER_MIN(3,20,0)
    190171# include <asm/tlbflush.h>
    191172#endif
    192173
    193174/* for set_pages_x() */
    194 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
     175#if RTLNX_VER_MIN(4,12,0)
    195176# include <asm/set_memory.h>
    196177#endif
    197178
    198179/* for __flush_tlb_all() */
    199 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86))
     180#if RTLNX_VER_MIN(2,6,28) && (defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86))
    200181# include <asm/tlbflush.h>
    201182#endif
    202183
    203 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
     184#if RTLNX_VER_MIN(3,7,0)
    204185# include <asm/smap.h>
    205186#else
     
    208189#endif
    209190
    210 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     191#if RTLNX_VER_MAX(2,6,0)
    211192# ifndef page_to_pfn
    212193#  define page_to_pfn(page) ((page) - mem_map)
     
    225206 * 2.4 / early 2.6 compatibility wrappers
    226207 */
    227 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 7)
     208#if RTLNX_VER_MAX(2,6,7)
    228209
    229210# ifndef MAX_JIFFY_OFFSET
     
    231212# endif
    232213
    233 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 29) || LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
     214# if RTLNX_VER_MAX(2,4,29) || RTLNX_VER_MIN(2,6,0)
    234215
    235216DECLINLINE(unsigned int) jiffies_to_msecs(unsigned long cJiffies)
     
    266247 * 2.4 compatibility wrappers
    267248 */
    268 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     249#if RTLNX_VER_MAX(2,6,0)
    269250
    270251# define prepare_to_wait(q, wait, state) \
     
    300281 * This sucks soooo badly on x86! Why don't they export __PAGE_KERNEL_EXEC so PAGE_KERNEL_EXEC would be usable?
    301282 */
    302 #if   LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8) && defined(RT_ARCH_AMD64)
     283#if   RTLNX_VER_MIN(2,6,8) && defined(RT_ARCH_AMD64)
    303284# define MY_PAGE_KERNEL_EXEC    PAGE_KERNEL_EXEC
    304 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 8) && defined(PAGE_KERNEL_EXEC) && defined(CONFIG_X86_PAE)
     285#elif RTLNX_VER_MIN(2,6,8) && defined(PAGE_KERNEL_EXEC) && defined(CONFIG_X86_PAE)
    305286# ifdef __PAGE_KERNEL_EXEC
    306287   /* >= 2.6.27 */
     
    320301#ifndef NO_REDHAT_HACKS
    321302/* accounting. */
    322 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     303# if RTLNX_VER_MAX(2,6,0)
    323304#  ifdef VM_ACCOUNT
    324305#   define USE_RHEL4_MUNMAP
     
    327308
    328309/* backported remap_page_range. */
    329 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     310# if RTLNX_VER_MAX(2,6,0)
    330311#  include <asm/tlb.h>
    331312#  ifdef tlb_vma /* probably not good enough... */
     
    361342#endif
    362343
    363 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
    364 # if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) /* The interface was removed, but we only need it for < 2.4.22, so who cares. */
     344#if RTLNX_VER_MIN(2,6,25)
     345# if RTLNX_VER_MAX(5,4,0) /* The interface was removed, but we only need it for < 2.4.22, so who cares. */
    365346#  define MY_SET_PAGES_EXEC(pPages, cPages)     set_pages_x(pPages, cPages)
    366347#  define MY_SET_PAGES_NOEXEC(pPages, cPages)   set_pages_nx(pPages, cPages)
     
    473454 * Whether the kernel support high resolution timers (Linux kernel versions
    474455 * 2.6.28 and later (hrtimer_add_expires_ns() & schedule_hrtimeout). */
    475 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     456#if RTLNX_VER_MIN(2,6,28)
    476457# define IPRT_LINUX_HAS_HRTIMER
    477458#endif
     
    480461 * Workqueue stuff, see initterm-r0drv-linux.c.
    481462 */
    482 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 41)
     463#if RTLNX_VER_MIN(2,5,41)
    483464typedef struct work_struct  RTR0LNXWORKQUEUEITEM;
    484465#else
  • trunk/src/VBox/Runtime/r0drv/linux/thread-r0drv-linux.c

    r82968 r85698  
    3434
    3535#include <iprt/asm.h>
    36 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 28) || defined(CONFIG_X86_SMAP)
     36#if RTLNX_VER_MAX(2,5,28) || defined(CONFIG_X86_SMAP)
    3737# include <iprt/asm-amd64-x86.h>
    3838#endif
     
    8888{
    8989    IPRT_LINUX_SAVE_EFL_AC();
    90 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 20)
     90#if RTLNX_VER_MIN(2,4,20)
    9191    yield();
    9292#else
     
    119119    if (c != 0)
    120120        return false;
    121 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 32)
     121# if RTLNX_VER_MIN(2,5,32)
    122122    if (in_atomic())
    123123        return false;
    124124# endif
    125 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 28)
     125# if RTLNX_VER_MIN(2,5,28)
    126126    if (irqs_disabled())
    127127        return false;
     
    139139{
    140140    Assert(hThread == NIL_RTTHREAD); RT_NOREF_PV(hThread);
    141 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 4)
     141#if RTLNX_VER_MIN(2,5,4)
    142142    return !!test_tsk_thread_flag(current, TIF_NEED_RESCHED);
    143143
    144 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 20)
     144#elif RTLNX_VER_MIN(2,4,20)
    145145    return !!need_resched();
    146146
    147 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 1, 110)
     147#elif RTLNX_VER_MIN(2,1,110)
    148148    return current->need_resched != 0;
    149149
  • trunk/src/VBox/Runtime/r0drv/linux/thread2-r0drv-linux.c

    r82968 r85698  
    3737#include "internal/thread.h"
    3838
    39 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
     39#if RTLNX_VER_MIN(4,11,0)
    4040    #include <uapi/linux/sched/types.h>
    4141#endif /* >= KERNEL_VERSION(4, 11, 0) */
     
    5555DECLHIDDEN(int) rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType)
    5656{
    57 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
     57#if RTLNX_VER_MIN(2,6,11)
    5858    /* See comment near MAX_RT_PRIO in linux/sched.h for details on
    5959       sched_priority. */
     
    123123
    124124
    125 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 4)
     125#if RTLNX_VER_MIN(2,6,4)
    126126/**
    127127 * Native kernel thread wrapper function.
     
    143143DECLHIDDEN(int) rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread)
    144144{
    145 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 4)
     145#if RTLNX_VER_MIN(2,6,4)
    146146    struct task_struct *NativeThread;
    147147    IPRT_LINUX_SAVE_EFL_AC();
  • trunk/src/VBox/Runtime/r0drv/linux/threadctxhooks-r0drv-linux.c

    r82968 r85698  
    4747 * got it backported.
    4848 */
    49 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18) && defined(CONFIG_PREEMPT_NOTIFIERS)
     49#if RTLNX_VER_MIN(2,6,18) && defined(CONFIG_PREEMPT_NOTIFIERS)
    5050
    5151
     
    7373    /** The linux callbacks. */
    7474    struct preempt_ops          PreemptOps;
    75 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 19) && defined(RT_ARCH_AMD64)
     75#if RTLNX_VER_MIN(3,1,19) && defined(RT_ARCH_AMD64)
    7676    /** Starting with 3.1.19, the linux kernel doesn't restore kernel RFLAGS during
    7777     * task switch, so we have to do that ourselves. (x86 code is not affected.) */
     
    110110#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    111111    ASMSetFlags(fSavedEFlags);
    112 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 19) && defined(RT_ARCH_AMD64)
     112# if RTLNX_VER_MIN(3,1,19) && defined(RT_ARCH_AMD64)
    113113    pThis->fSavedRFlags = fSavedEFlags;
    114114# endif
     
    143143
    144144#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    145 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 19) && defined(RT_ARCH_AMD64)
     145# if RTLNX_VER_MIN(3,1,19) && defined(RT_ARCH_AMD64)
    146146    fSavedEFlags &= ~RT_BIT_64(18) /*X86_EFL_AC*/;
    147147    fSavedEFlags |= pThis->fSavedRFlags & RT_BIT_64(18) /*X86_EFL_AC*/;
     
    199199    pThis->PreemptOps.sched_in  = rtThreadCtxHooksLnxSchedIn;
    200200
    201 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
     201#if RTLNX_VER_MIN(4,2,0)
    202202    preempt_notifier_inc();
    203203#endif
     
    236236    }
    237237
    238 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
     238#if RTLNX_VER_MIN(4,2,0)
    239239    preempt_notifier_dec();
    240240#endif
  • trunk/src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c

    r85208 r85698  
    3333#include "internal/iprt.h"
    3434/* Make sure we have the setting functions we need for RTTimeNow: */
    35 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
     35#if RTLNX_VER_MAX(2,6,16)
    3636# define RTTIME_INCL_TIMEVAL
    37 #elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
     37#elif RTLNX_VER_MAX(3,17,0)
    3838# define RTTIME_INCL_TIMESPEC
    3939#endif
     
    4545DECLINLINE(uint64_t) rtTimeGetSystemNanoTS(void)
    4646{
    47 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
     47#if RTLNX_VER_MIN(5,6,0)
    4848    /*
    4949     * Starting with kernel version 5.6-rc3 only 64-bit time interfaces
     
    5757    return u64;
    5858
    59 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16) /* This must match timer-r0drv-linux.c! */
     59#elif RTLNX_VER_MIN(2,6,16) /* This must match timer-r0drv-linux.c! */
    6060    /*
    6161     * Use ktime_get_ts, this is also what clock_gettime(CLOCK_MONOTONIC,) is using.
     
    6767    return u64;
    6868
    69 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 60)
     69#elif RTLNX_VER_MIN(2,5,60)
    7070    /*
    7171     * Seems there is no way of getting to the exact source of
     
    189189{
    190190    IPRT_LINUX_SAVE_EFL_AC();
    191 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
     191#if RTLNX_VER_MIN(3,17,0)
    192192    struct timespec64 Ts;
    193193    ktime_get_real_ts64(&Ts);   /* ktime_get_real_ts64 was added as a macro in 3.17, function since 4.18. */
     
    195195    return RTTimeSpecSetTimespec64(pTime, &Ts);
    196196
    197 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
     197#elif RTLNX_VER_MIN(2,6,16)
    198198    struct timespec Ts;
    199199    ktime_get_real_ts(&Ts);     /* ktime_get_real_ts was removed in Linux 4.20. */
  • trunk/src/VBox/Runtime/r0drv/linux/timer-r0drv-linux.c

    r82968 r85698  
    5151#endif
    5252
    53 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
     53#if RTLNX_VER_MAX(2,6,31)
    5454# define mod_timer_pinned               mod_timer
    5555# define HRTIMER_MODE_ABS_PINNED        HRTIMER_MODE_ABS
     
    368368        if (fPinned)
    369369        {
    370 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
     370# if RTLNX_VER_MIN(4,8,0)
    371371            mod_timer(&pSubTimer->u.Std.LnxTimer, pSubTimer->u.Std.ulNextJiffies);
    372372# else
     
    721721
    722722
    723 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
     723#if RTLNX_VER_MIN(4,15,0)
    724724/**
    725725 * Timer callback function for standard timers.
     
    840840            if (pTimer->fSpecificCpu || pTimer->fAllCpus)
    841841            {
    842 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
     842# if RTLNX_VER_MIN(4,8,0)
    843843                mod_timer(&pSubTimer->u.Std.LnxTimer, ulNextJiffies);
    844844# else
     
    903903                    if (pTimer->fSpecificCpu || pTimer->fAllCpus)
    904904                    {
    905 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
     905# if RTLNX_VER_MIN(4,8,0)
    906906                        mod_timer(&pSubTimer->u.Std.LnxTimer, pSubTimer->u.Std.ulNextJiffies);
    907907# else
     
    15201520        /* For paranoid reasons, defer actually destroying the semaphore when
    15211521           in atomic or interrupt context. */
    1522 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 32)
     1522#if RTLNX_VER_MIN(2,5,32)
    15231523        if (in_atomic() || in_interrupt())
    15241524#else
     
    16211621#endif
    16221622        {
    1623 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
     1623#if RTLNX_VER_MIN(4,15,0)
    16241624            timer_setup(&pTimer->aSubTimers[iCpu].u.Std.LnxTimer, rtTimerLinuxStdCallback, TIMER_PINNED);
    1625 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
     1625#elif RTLNX_VER_MIN(4,8,0)
    16261626            init_timer_pinned(&pTimer->aSubTimers[iCpu].u.Std.LnxTimer);
    16271627#else
    16281628            init_timer(&pTimer->aSubTimers[iCpu].u.Std.LnxTimer);
    16291629#endif
    1630 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
     1630#if RTLNX_VER_MAX(4,15,0)
    16311631            pTimer->aSubTimers[iCpu].u.Std.LnxTimer.data        = (unsigned long)&pTimer->aSubTimers[iCpu];
    16321632            pTimer->aSubTimers[iCpu].u.Std.LnxTimer.function    = rtTimerLinuxStdCallback;
     
    16871687#endif
    16881688    /* */
    1689 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) || LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
     1689#if RTLNX_VER_MAX(4,9,0) || RTLNX_VER_MIN(4,13,0)
    16901690    /* On 4.9, 4.10 and 4.12 we've observed tstRTR0Timer failures of the omni timer tests
    16911691       where we get about half of the ticks we want.  The failing test is using this value
  • trunk/src/VBox/Runtime/r0drv/linux/waitqueue-r0drv-linux.h

    r85649 r85698  
    184184     * Initialize the wait queue related bits.
    185185     */
    186 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 39)
     186#if RTLNX_VER_MIN(2,5,39)
    187187    init_wait((&pWait->WaitQE));
    188188#else
Note: See TracChangeset for help on using the changeset viewer.

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