VirtualBox

Changeset 85698 in vbox for trunk/src/VBox/Runtime/r0drv


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/Runtime/r0drv/linux
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • 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