Changeset 85698 in vbox for trunk/src/VBox
- Timestamp:
- Aug 11, 2020 5:05:29 PM (4 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c
r82968 r85698 36 36 #include "the-linux-kernel.h" 37 37 38 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,15)38 #if RTLNX_VER_MIN(2,6,15) 39 39 # define VBOXGUEST_WITH_INPUT_DRIVER 40 40 #endif 41 41 42 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15,0)42 #if RTLNX_VER_MIN(4,15,0) 43 43 # define CONST_4_15 const 44 44 #else … … 52 52 #include <linux/miscdevice.h> 53 53 #include <linux/poll.h> 54 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,28)54 #if RTLNX_VER_MIN(2,6,28) 55 55 # include <linux/tty.h> 56 56 #endif … … 90 90 91 91 /* 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) 93 93 # define kgid_t gid_t 94 94 # define kuid_t uid_t … … 142 142 static VMMDevReqMouseStatus *g_pMouseStatusReq; 143 143 #endif 144 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,0)144 #if RTLNX_VER_MIN(2,6,0) 145 145 /** Whether we've create the logger or not. */ 146 146 static volatile bool g_fLoggerCreated; … … 364 364 * @param pRegs Register set. Removed in 2.6.19. 365 365 */ 366 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,19) && !defined(DOXYGEN_RUNNING)366 #if RTLNX_VER_MIN(2,6,19) && !defined(DOXYGEN_RUNNING) 367 367 static irqreturn_t vgdrvLinuxISR(int iIrq, void *pvDevId) 368 368 #else … … 385 385 rc = request_irq(g_pPciDev->irq, 386 386 vgdrvLinuxISR, 387 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,20)387 #if RTLNX_VER_MIN(2,6,20) 388 388 IRQF_SHARED, 389 389 #else … … 477 477 g_pInputDevice->open = vboxguestOpenInputDevice; 478 478 g_pInputDevice->close = vboxguestCloseInputDevice; 479 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,22)479 # if RTLNX_VER_MAX(2,6,22) 480 480 g_pInputDevice->cdev.dev = &g_pPciDev->dev; 481 481 # else … … 596 596 if (RT_SUCCESS(rc)) 597 597 { 598 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,0)598 #if RTLNX_VER_MIN(2,6,0) 599 599 RTLogGroupSettings(pRelLogger, g_szLogGrp); 600 600 RTLogFlags(pRelLogger, g_szLogFlags); … … 603 603 RTLogRelSetDefaultInstance(pRelLogger); 604 604 } 605 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,0)605 #if RTLNX_VER_MIN(2,6,0) 606 606 g_fLoggerCreated = true; 607 607 #endif … … 616 616 * Call the common device extension initializer. 617 617 */ 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) 619 619 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) 621 621 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) 623 623 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) 625 625 VBOXOSTYPE enmOSType = VBOXOSTYPE_Linux24_x64; 626 626 #else … … 740 740 DECLINLINE(RTUID) vgdrvLinuxGetUid(void) 741 741 { 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) 744 744 return from_kuid(current_user_ns(), current->cred->uid); 745 745 # else … … 760 760 DECLINLINE(bool) vgdrvLinuxIsGroupZero(kgid_t gid) 761 761 { 762 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5,0)762 #if RTLNX_VER_MIN(3,5,0) 763 763 return from_kgid(current_user_ns(), gid); 764 764 #else … … 793 793 uint32_t fRet = VMMDEV_REQUESTOR_CON_DONT_KNOW; 794 794 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(). */ 796 796 /* 797 797 * Check for tty0..63, ASSUMING that these are only used for the physical console. … … 800 800 if (pTty) 801 801 { 802 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2,0)802 # if RTLNX_VER_MIN(4,2,0) 803 803 const char *pszName = tty_name(pTty); 804 804 # else … … 879 879 pFilp, pFilp->private_data, RTProcSelf(), current->pid, current->comm)); 880 880 881 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,28)881 #if RTLNX_VER_MAX(2,6,28) 882 882 /* This housekeeping was needed in older kernel versions to ensure that 883 883 * the file pointer didn't get left on the polling queue. */ … … 1188 1188 1189 1189 1190 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,0)1190 #if RTLNX_VER_MIN(2,6,0) 1191 1191 1192 1192 /** log and dbg_log parameter setter. */ -
trunk/src/VBox/Additions/common/VBoxGuest/linux/files_vboxguest
r83917 r85698 70 70 ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \ 71 71 ${PATH_ROOT}/include/iprt/x86.h=>include/iprt/x86.h \ 72 ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \ 72 73 ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \ 73 74 ${PATH_ROOT}/include/VBox/err.h=>include/VBox/err.h \ -
trunk/src/VBox/Additions/linux/sharedfolders/dirops.c
r82968 r85698 36 36 #include <iprt/err.h> 37 37 38 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7,0)38 #if RTLNX_VER_MAX(4,7,0) 39 39 # define d_in_lookup(a_pDirEntry) (d_unhashed(a_pDirEntry)) 40 40 #endif … … 280 280 */ 281 281 DECL_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) 283 283 struct dir_context *ctx, 284 284 # else … … 291 291 int rc = vbsf_nlscpy(pSuperInfo, szDstName, sizeof(szDstName), pszSrcName, cchSrcName); 292 292 if (rc == 0) { 293 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11,0)293 #if RTLNX_VER_MIN(3,11,0) 294 294 return dir_emit(ctx, szDstName, strlen(szDstName), d_ino, d_type); 295 295 #else … … 327 327 * c. filldir returns an error (see comment on that) 328 328 */ 329 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11,0)329 #if RTLNX_VER_MIN(3,11,0) 330 330 static int vbsf_dir_iterate(struct file *dir, struct dir_context *ctx) 331 331 #else … … 333 333 #endif 334 334 { 335 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11,0)335 #if RTLNX_VER_MIN(3,11,0) 336 336 loff_t offPos = ctx->pos; 337 337 #else … … 403 403 */ 404 404 if (offPos < 2) { 405 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11,0)405 #if RTLNX_VER_MIN(3,11,0) 406 406 if (offPos == 0) { 407 407 if (dir_emit_dot(dir, ctx)) … … 431 431 } 432 432 if (offPos == 1) { 433 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,5)433 # if RTLNX_VER_MIN(2,5,5) 434 434 rc = filldir(opaque, "..", 2, 1, parent_ino(VBSF_GET_F_DENTRY(dir)), DT_DIR); 435 435 # else … … 506 506 bool fContinue; 507 507 if (pSuperInfo->fNlsIsUtf8) { 508 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11,0)508 #if RTLNX_VER_MIN(3,11,0) 509 509 fContinue = dir_emit(ctx, pEntry->name.String.ach, cchSrcName, d_ino, d_type); 510 510 #else … … 512 512 #endif 513 513 } else { 514 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11,0)514 #if RTLNX_VER_MIN(3,11,0) 515 515 fContinue = vbsf_dir_emit_nls(ctx, pEntry->name.String.ach, cchSrcName, d_ino, d_type, pSuperInfo); 516 516 #else … … 536 536 offPos += 1; 537 537 dir->f_pos = offPos; 538 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11,0)538 #if RTLNX_VER_MIN(3,11,0) 539 539 ctx->pos = offPos; 540 540 #endif … … 555 555 struct file_operations vbsf_dir_fops = { 556 556 .open = vbsf_dir_open, 557 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7,0)557 #if RTLNX_VER_MIN(4,7,0) 558 558 .iterate_shared = vbsf_dir_iterate, 559 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11,0)559 #elif RTLNX_VER_MIN(3,11,0) 560 560 .iterate = vbsf_dir_iterate, 561 561 #else … … 564 564 .release = vbsf_dir_release, 565 565 .read = generic_read_dir, 566 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,37)566 #if RTLNX_VER_MIN(2,6,37) 567 567 .llseek = generic_file_llseek 568 568 #endif … … 588 588 if (sf_new_i) { 589 589 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) 591 591 struct inode *pInode = iget_locked(parent->i_sb, iNodeNo); 592 592 #else … … 614 614 if (fInstantiate) 615 615 d_instantiate(dentry, pInode); 616 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,25)616 #if RTLNX_VER_MIN(2,4,25) 617 617 unlock_new_inode(pInode); 618 618 #endif … … 632 632 DECLINLINE(void) vbsf_d_add_inode(struct dentry *dentry, struct inode *pNewInode) 633 633 { 634 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,38)634 #if RTLNX_VER_MIN(2,6,38) 635 635 Assert(dentry->d_op == &vbsf_dentry_ops); /* (taken from the superblock) */ 636 636 #else … … 651 651 */ 652 652 static 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) 654 654 , unsigned int flags 655 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,0)655 #elif RTLNX_VER_MIN(2,6,0) 656 656 , struct nameidata *nd 657 657 #endif … … 664 664 int rc; 665 665 666 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6,0)666 #if RTLNX_VER_MIN(3,6,0) 667 667 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) 669 669 SFLOGFLOW(("vbsf_inode_lookup: parent=%p dentry=%p nd=%p{.flags=%#x}\n", parent, dentry, nd, nd ? nd->flags : 0)); 670 670 #else … … 920 920 921 921 922 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16,0)922 #if RTLNX_VER_MIN(3,16,0) 923 923 /** 924 924 * More atomic way of handling creation. … … 930 930 static int vbsf_inode_atomic_open(struct inode *pDirInode, struct dentry *dentry, struct file *file, unsigned fOpen, 931 931 umode_t fMode 932 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 19,0)932 # if RTLNX_VER_MAX(4,19,0) 933 933 , int *opened 934 934 # endif … … 982 982 * and call finish_open() to do the remaining open() work. 983 983 */ 984 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19,0)984 # if RTLNX_VER_MIN(4,19,0) 985 985 if (fCreated) 986 986 file->f_mode |= FMODE_CREATED; … … 1045 1045 * @returns 0 on success, Linux error code otherwise 1046 1046 */ 1047 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6,0) || defined(DOXYGEN_RUNNING)1047 #if RTLNX_VER_MIN(3,6,0) || defined(DOXYGEN_RUNNING) 1048 1048 static 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) 1050 1050 static 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) 1052 1052 static int vbsf_inode_create(struct inode *parent, struct dentry *dentry, int mode, struct nameidata *nd) 1053 1053 #else … … 1058 1058 | SHFL_CF_ACT_FAIL_IF_EXISTS 1059 1059 | 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) 1061 1061 /* Clear the RD flag if write-only access requested. Otherwise assume we 1062 1062 need write access to create stuff. */ … … 1082 1082 * @returns 0 on success, Linux error code otherwise 1083 1083 */ 1084 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3,0)1084 #if RTLNX_VER_MIN(3,3,0) 1085 1085 static int vbsf_inode_mkdir(struct inode *parent, struct dentry *dentry, umode_t mode) 1086 1086 #else … … 1203 1203 uint32_t fRename = (old_dentry->d_inode->i_mode & S_IFDIR ? SHFL_RENAME_DIR : SHFL_RENAME_FILE) 1204 1204 | SHFL_RENAME_REPLACE_IF_EXISTS; 1205 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15,0)1205 #if RTLNX_VER_MIN(3,15,0) 1206 1206 if (!(flags & ~RENAME_NOREPLACE)) { 1207 1207 if (flags & RENAME_NOREPLACE) … … 1273 1273 rc = -EXDEV; 1274 1274 } 1275 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15,0)1275 #if RTLNX_VER_MIN(3,15,0) 1276 1276 } else { 1277 1277 SFLOGFLOW(("vbsf_inode_rename: Unsupported flags: %#x\n", flags)); … … 1285 1285 1286 1286 1287 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9,0)1287 #if RTLNX_VER_MAX(4,9,0) 1288 1288 /** 1289 1289 * The traditional rename interface without any flags. … … 1373 1373 struct inode_operations vbsf_dir_iops = { 1374 1374 .lookup = vbsf_inode_lookup, 1375 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16,0)1375 #if RTLNX_VER_MIN(3,16,0) 1376 1376 .atomic_open = vbsf_inode_atomic_open, 1377 1377 #endif … … 1381 1381 .rmdir = vbsf_inode_rmdir, 1382 1382 .unlink = vbsf_inode_unlink, 1383 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9,0)1383 #if RTLNX_VER_MIN(4,9,0) 1384 1384 .rename = vbsf_inode_rename, 1385 1385 #else 1386 1386 .rename = vbsf_inode_rename_no_flags, 1387 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15,0)1387 # if RTLNX_VER_MIN(3,15,0) 1388 1388 .rename2 = vbsf_inode_rename, 1389 1389 # endif 1390 1390 #endif 1391 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,18)1391 #if RTLNX_VER_MIN(2,5,18) 1392 1392 .getattr = vbsf_inode_getattr, 1393 1393 #else -
trunk/src/VBox/Additions/linux/sharedfolders/files_vboxsf
r82968 r85698 45 45 ${PATH_ROOT}/include/iprt/uni.h=>include/iprt/uni.h \ 46 46 ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \ 47 ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \ 47 48 ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \ 48 49 ${PATH_ROOT}/include/VBox/err.h=>include/VBox/err.h \ -
trunk/src/VBox/Additions/linux/sharedfolders/lnkops.c
r82968 r85698 108 108 } 109 109 110 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5,0)110 #if RTLNX_VER_MIN(4,5,0) 111 111 112 112 /** … … 147 147 #else /* < 4.5 */ 148 148 149 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,8)149 # if RTLNX_VER_MAX(2,6,8) 150 150 /** 151 151 * Reads the link into the given buffer. … … 183 183 * Follow link in dentry. 184 184 */ 185 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2,0)185 # if RTLNX_VER_MIN(4,2,0) 186 186 static 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) 188 188 static void *vbsf_follow_link(struct dentry *dentry, struct nameidata *nd) 189 189 # else … … 213 213 */ 214 214 vbsf_dentry_chain_increase_ttl(dentry); 215 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2,0)215 # if RTLNX_VER_MIN(4,2,0) 216 216 *cookie = pszTarget; 217 217 return pszTarget; 218 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,8)218 # elif RTLNX_VER_MIN(2,6,8) 219 219 nd_set_link(nd, pszTarget); 220 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,13)220 # if RTLNX_VER_MIN(2,6,13) 221 221 return NULL; 222 222 # else … … 241 241 rc = -ENOMEM; 242 242 } 243 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2,0)243 # if RTLNX_VER_MIN(4,2,0) 244 244 *cookie = ERR_PTR(rc); 245 245 return (const char *)ERR_PTR(rc); 246 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,8)246 # elif RTLNX_VER_MIN(2,6,8) 247 247 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) 249 249 return NULL; 250 250 # else … … 256 256 } 257 257 258 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,8)258 # if RTLNX_VER_MIN(2,6,8) 259 259 /** 260 260 * For freeing target link buffer allocated by vbsf_follow_link. … … 262 262 * For kernels before 2.6.8 memory isn't being kept around. 263 263 */ 264 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2,0)264 # if RTLNX_VER_MIN(4,2,0) 265 265 static 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) 267 267 static void vbsf_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) 268 268 # else … … 270 270 # endif 271 271 { 272 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,13)272 # if RTLNX_VER_MIN(2,6,13) 273 273 char *page = cookie; 274 274 # else … … 287 287 */ 288 288 struct 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) 291 291 .readlink = generic_readlink, 292 292 # else … … 294 294 # endif 295 295 #endif 296 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5,0)296 #if RTLNX_VER_MIN(4,5,0) 297 297 .get_link = vbsf_get_link 298 298 #else 299 299 .follow_link = vbsf_follow_link, 300 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,8)300 # if RTLNX_VER_MIN(2,6,8) 301 301 .put_link = vbsf_put_link, 302 302 # endif -
trunk/src/VBox/Additions/linux/sharedfolders/regops.c
r85693 r85698 35 35 #include "vfsmod.h" 36 36 #include <linux/uio.h> 37 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,32)37 #if RTLNX_VER_MIN(2,5,32) 38 38 # include <linux/aio.h> /* struct kiocb before 4.1 */ 39 39 #endif 40 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,12)40 #if RTLNX_VER_MIN(2,5,12) 41 41 # include <linux/buffer_head.h> 42 42 #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) 45 44 # include <linux/writeback.h> 46 45 #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) 49 47 # include <linux/splice.h> 50 48 #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) 53 50 # include <linux/pipe_fs_i.h> 54 51 #endif 55 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,10)52 #if RTLNX_VER_MIN(2,4,10) 56 53 # include <linux/swap.h> /* for mark_page_accessed */ 57 54 #endif 58 55 #include <iprt/err.h> 59 56 60 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,18)57 #if RTLNX_VER_MAX(2,6,18) 61 58 # define SEEK_END 2 62 59 #endif 63 60 64 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16,0)61 #if RTLNX_VER_MAX(3,16,0) 65 62 # 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) 67 64 # define iter_is_iovec(a_pIter) ( !((a_pIter)->type & (ITER_KVEC | ITER_BVEC)) ) 68 65 #endif 69 66 70 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 17,0)67 #if RTLNX_VER_MAX(4,17,0) 71 68 # define vm_fault_t int 72 69 #endif 73 70 74 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5,20)71 #if RTLNX_VER_MAX(2,5,20) 75 72 # define pgoff_t unsigned long 76 73 #endif 77 74 78 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5,12)75 #if RTLNX_VER_MAX(2,5,12) 79 76 # define PageUptodate(a_pPage) Page_Uptodate(a_pPage) 80 77 #endif … … 84 81 * Structures and Typedefs * 85 82 *********************************************************************************************************************************/ 86 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16,0)83 #if RTLNX_VER_MAX(3,16,0) 87 84 struct vbsf_iov_iter { 88 85 unsigned int type; … … 107 104 #endif 108 105 109 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,19)106 #if RTLNX_VER_MIN(2,6,19) 110 107 /** Used by vbsf_iter_lock_pages() to keep the first page of the next segment. */ 111 108 struct vbsf_iter_stash { … … 113 110 size_t off; 114 111 size_t cb; 115 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11,0)112 # if RTLNX_VER_MAX(4,11,0) 116 113 size_t offFromEnd; 117 114 struct iov_iter Copy; … … 120 117 #endif /* >= 3.16.0 */ 121 118 /** Initializer for struct vbsf_iter_stash. */ 122 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11,0)119 #if RTLNX_VER_MIN(4,11,0) 123 120 # define VBSF_ITER_STASH_INITIALIZER { NULL, 0 } 124 121 #else … … 140 137 * Provide more recent uio.h functionality to older kernels. * 141 138 *********************************************************************************************************************************/ 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) 143 140 144 141 /** … … 299 296 300 297 #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) 302 299 303 300 /** This is for implementing cMaxPage on 3.16 which doesn't have it. */ … … 319 316 320 317 #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) 322 319 323 320 static size_t copy_from_iter(uint8_t *pbDst, size_t cbToCopy, struct iov_iter *pSrcIter) … … 325 322 size_t const cbTotal = cbToCopy; 326 323 Assert(iov_iter_count(pSrcIter) >= cbToCopy); 327 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16,0)324 # if RTLNX_VER_MIN(3,16,0) 328 325 if (pSrcIter->type & ITER_BVEC) { 329 326 while (cbToCopy > 0) { … … 364 361 size_t const cbTotal = cbToCopy; 365 362 Assert(iov_iter_count(pDstIter) >= cbToCopy); 366 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16,0)363 # if RTLNX_VER_MIN(3,16,0) 367 364 if (pDstIter->type & ITER_BVEC) { 368 365 while (cbToCopy > 0) { … … 555 552 *********************************************************************************************************************************/ 556 553 557 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,6)554 #if RTLNX_VER_MAX(2,6,6) 558 555 /** Any writable mappings? */ 559 556 DECLINLINE(bool) mapping_writably_mapped(struct address_space const *mapping) 560 557 { 561 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,6)558 # if RTLNX_VER_MIN(2,5,6) 562 559 return !list_empty(&mapping->i_mmap_shared); 563 560 # else … … 568 565 569 566 570 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5,12)567 #if RTLNX_VER_MAX(2,5,12) 571 568 /** Missing in 2.4.x, so just stub it for now. */ 572 569 DECLINLINE(bool) PageWriteback(struct page const *page) … … 604 601 *********************************************************************************************************************************/ 605 602 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) 610 606 # define LOCK_PIPE(a_pPipe) do { if ((a_pPipe)->inode) mutex_lock(&(a_pPipe)->inode->i_mutex); } while (0) 611 607 # define UNLOCK_PIPE(a_pPipe) do { if ((a_pPipe)->inode) mutex_unlock(&(a_pPipe)->inode->i_mutex); } while (0) … … 647 643 648 644 #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) 651 646 652 647 /** Verify pipe buffer content (needed for page-cache to ensure idle page). */ … … 721 716 static struct pipe_buf_operations vbsf_pipe_buf_ops = { 722 717 .can_merge = 0, 723 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,23)718 # if RTLNX_VER_MIN(2,6,23) 724 719 .confirm = vbsf_pipe_buf_confirm, 725 720 # else … … 754 749 pPipeBuf->len = cbThisPage; 755 750 pPipeBuf->offset = offPg0; 756 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,23)751 # if RTLNX_VER_MIN(2,6,23) 757 752 pPipeBuf->private = 0; 758 753 # endif … … 895 890 896 891 #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) 899 893 900 894 /** … … 1017 1011 pPipeBuf = &pPipe->bufs[pPipe->curbuf]; 1018 1012 1019 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,30)1013 # if RTLNX_VER_MAX(2,6,30) 1020 1014 fNeedWakeUp |= pPipe->inode != NULL; 1021 1015 # else … … 1092 1086 #endif /* 2.6.17 <= LINUX_VERSION_CODE < 3.16.0 */ 1093 1087 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) 1096 1089 /** 1097 1090 * Our own senfile implementation that does not go via the page cache like … … 1099 1092 */ 1100 1093 static 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) 1102 1095 void *pvUser 1103 1096 # else … … 1161 1154 read_descriptor_t RdDesc; 1162 1155 RdDesc.count = cbToSend; 1163 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,8)1156 # if RTLNX_VER_MIN(2,6,8) 1164 1157 RdDesc.arg.data = pvUser; 1165 1158 # else … … 1290 1283 DECLINLINE(void) vbsf_put_page(struct page *pPage) 1291 1284 { 1292 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6,0)1285 #if RTLNX_VER_MIN(4,6,0) 1293 1286 put_page(pPage); 1294 1287 #else … … 1301 1294 DECLINLINE(void) vbsf_get_page(struct page *pPage) 1302 1295 { 1303 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6,0)1296 #if RTLNX_VER_MIN(4,6,0) 1304 1297 get_page(pPage); 1305 1298 #else … … 1409 1402 * Check that this is valid user memory that is actually in the kernel range. 1410 1403 */ 1411 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0,0) || defined(RHEL_81)1404 #if RTLNX_VER_MIN(5,0,0) || defined(RHEL_81) 1412 1405 if ( access_ok((void *)uPtrFrom, cPages << PAGE_SHIFT) 1413 1406 && uPtrFrom >= USER_DS.seg) … … 1476 1469 static ssize_t vbsf_reg_read_mapped(struct file *file, char /*__user*/ *buf, size_t size, loff_t *off) 1477 1470 { 1478 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16,0)1471 #if RTLNX_VER_MIN(3,16,0) 1479 1472 struct iovec iov = { .iov_base = buf, .iov_len = size }; 1480 1473 struct iov_iter iter; … … 1491 1484 return cbRet; 1492 1485 1493 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,19)1486 #elif RTLNX_VER_MIN(2,6,19) 1494 1487 struct iovec iov = { .iov_base = buf, .iov_len = size }; 1495 1488 struct kiocb kiocb; … … 1778 1771 if (cbToCopy == PAGE_SIZE) 1779 1772 SetPageUptodate(pDstPage); 1780 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,10)1773 # if RTLNX_VER_MIN(2,4,10) 1781 1774 mark_page_accessed(pDstPage); 1782 1775 # endif … … 1987 1980 && mapping->nrpages > 0 1988 1981 && mapping_writably_mapped(mapping)) { 1989 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,32)1982 #if RTLNX_VER_MIN(2,6,32) 1990 1983 int err = filemap_fdatawait_range(mapping, pos, pos + size - 1); 1991 1984 if (err) … … 2079 2072 } 2080 2073 2081 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,19)2074 #if RTLNX_VER_MIN(2,6,19) 2082 2075 2083 2076 /** … … 2147 2140 SFLOG3(("vbsf_iter_lock_pages: Picked up stashed page: %#zx LB %#zx\n", offPage0, cbChunk)); 2148 2141 } else { 2149 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11,0)2142 # if RTLNX_VER_MAX(4,11,0) 2150 2143 /* 2151 2144 * Copy out our starting point to assist rewinding. … … 2166 2159 ssize_t cbSegRet; 2167 2160 if (cPages == 0) { 2168 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19,0)2161 # if RTLNX_VER_MAX(3,19,0) 2169 2162 while (!iov_iter_single_seg_count(iter)) /* Old code didn't skip empty segments which caused EFAULTs. */ 2170 2163 iov_iter_advance(iter, 0); … … 2259 2252 * and vbsf_lock_user_pages_failed_check_kernel() as well. 2260 2253 */ 2261 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11,0)2254 # if RTLNX_VER_MAX(4,11,0) 2262 2255 pStash->offFromEnd = iov_iter_count(iter); 2263 2256 pStash->Copy = *iter; … … 2274 2267 } 2275 2268 2276 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19,0)2269 # if RTLNX_VER_MIN(3,19,0) 2277 2270 pbBuf = iter->kvec->iov_base + iter->iov_offset; 2278 2271 # else … … 2339 2332 } 2340 2333 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) 2342 2335 iov_iter_revert(iter, cbToRewind + cbExtra); 2343 2336 return true; … … 2369 2362 { 2370 2363 size_t cPages; 2371 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16,0)2364 # if RTLNX_VER_MIN(3,16,0) 2372 2365 if (iter_is_iovec(iter) || (iter->type & ITER_KVEC)) { 2373 2366 #endif … … 2429 2422 if (cPagesSpan > cPages) 2430 2423 cPages = cPagesSpan; 2431 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16,0)2424 # if RTLNX_VER_MIN(3,16,0) 2432 2425 } else { 2433 2426 /* Won't bother with accurate counts for the next two types, just make … … 2568 2561 * @param iter The I/O vector iterator describing the buffer. 2569 2562 */ 2570 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16,0)2563 # if RTLNX_VER_MIN(3,16,0) 2571 2564 static ssize_t vbsf_reg_read_iter(struct kiocb *kio, struct iov_iter *iter) 2572 2565 # else … … 2574 2567 # endif 2575 2568 { 2576 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16,0)2569 # if RTLNX_VER_MAX(3,16,0) 2577 2570 struct vbsf_iov_iter fake_iter = VBSF_IOV_ITER_INITIALIZER(cSegs, iov, 0 /*write*/); 2578 2571 struct vbsf_iov_iter *iter = &fake_iter; … … 2602 2595 */ 2603 2596 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) 2605 2598 return generic_file_read_iter(kio, iter); 2606 2599 # else … … 2794 2787 * @param iter The I/O vector iterator describing the buffer. 2795 2788 */ 2796 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16,0)2789 # if RTLNX_VER_MIN(3,16,0) 2797 2790 static ssize_t vbsf_reg_write_iter(struct kiocb *kio, struct iov_iter *iter) 2798 2791 # else … … 2800 2793 # endif 2801 2794 { 2802 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16,0)2795 # if RTLNX_VER_MAX(3,16,0) 2803 2796 struct vbsf_iov_iter fake_iter = VBSF_IOV_ITER_INITIALIZER(cSegs, iov, 1 /*write*/); 2804 2797 struct vbsf_iov_iter *iter = &fake_iter; … … 2811 2804 struct vbsf_reg_info *sf_r = kio->ki_filp->private_data; 2812 2805 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) 2814 2807 loff_t offFile = kio->ki_pos; 2815 2808 # endif 2816 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1,0)2809 # if RTLNX_VER_MIN(4,1,0) 2817 2810 bool const fAppend = RT_BOOL(kio->ki_flags & IOCB_APPEND); 2818 2811 # else … … 2854 2847 && mapping->nrpages > 0 2855 2848 && mapping_writably_mapped(mapping)) { 2856 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,32)2849 # if RTLNX_VER_MIN(2,6,32) 2857 2850 int err = filemap_fdatawait_range(mapping, offFile, offFile + cbToWrite - 1); 2858 2851 if (err) … … 2890 2883 i_size_write(inode, offFile); 2891 2884 2892 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11,0)2885 # if RTLNX_VER_MIN(4,11,0) 2893 2886 if ((size_t)cbRet < cbToWrite) 2894 2887 iov_iter_revert(iter, cbToWrite - cbRet); … … 3129 3122 && mapping->nrpages > 0 3130 3123 /** @todo && last writable handle */ ) { 3131 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,25)3124 #if RTLNX_VER_MIN(2,4,25) 3132 3125 if (filemap_fdatawrite(mapping) != -EIO) 3133 3126 #else … … 3176 3169 } 3177 3170 3178 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,8)3171 #if RTLNX_VER_MIN(2,4,8) 3179 3172 return generic_file_llseek(file, off, whence); 3180 3173 #else … … 3192 3185 * well as any host interaction with the file. 3193 3186 */ 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 */) 3196 3189 static int vbsf_reg_fsync(struct file *file, loff_t start, loff_t end, int datasync) 3197 3190 { 3198 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16,0)3191 # if RTLNX_VER_MIN(3,16,0) 3199 3192 return __generic_file_fsync(file, start, end, datasync); 3200 3193 # else … … 3202 3195 # endif 3203 3196 } 3204 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,35)3197 #elif RTLNX_VER_MIN(2,6,35) 3205 3198 static int vbsf_reg_fsync(struct file *file, int datasync) 3206 3199 { … … 3210 3203 static int vbsf_reg_fsync(struct file *file, struct dentry *dentry, int datasync) 3211 3204 { 3212 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,31)3205 # if RTLNX_VER_MIN(2,6,31) 3213 3206 return simple_fsync(file, dentry, datasync); 3214 3207 # else … … 3219 3212 /** @todo What about file_fsync()? (<= 2.5.11) */ 3220 3213 3221 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,12)3214 # if RTLNX_VER_MIN(2,5,12) 3222 3215 rc = sync_mapping_buffers(inode->i_mapping); 3223 3216 if ( rc == 0 … … 3240 3233 */ 3241 3234 rc = fsync_inode_buffers(inode); 3242 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,10)3235 # if RTLNX_VER_MIN(2,4,10) 3243 3236 if (rc == 0 && datasync) 3244 3237 rc = fsync_inode_data_buffers(inode); … … 3252 3245 3253 3246 3254 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5,0)3247 #if RTLNX_VER_MIN(4,5,0) 3255 3248 /** 3256 3249 * Copy a datablock from one file to another on the host side. … … 3279 3272 Assert(pInodeInfoDst->u32Magic == SF_INODE_INFO_MAGIC); 3280 3273 3281 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11,0)3274 # if RTLNX_VER_MAX(4,11,0) 3282 3275 if (!S_ISREG(pInodeSrc->i_mode) || !S_ISREG(pInodeDst->i_mode)) 3283 3276 return S_ISDIR(pInodeSrc->i_mode) || S_ISDIR(pInodeDst->i_mode) ? -EISDIR : -EINVAL; … … 3323 3316 3324 3317 /* Generic page fault callback: */ 3325 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11,0)3318 # if RTLNX_VER_MIN(4,11,0) 3326 3319 static vm_fault_t vbsf_vmlog_fault(struct vm_fault *vmf) 3327 3320 { … … 3332 3325 return rc; 3333 3326 } 3334 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,23)3327 # elif RTLNX_VER_MIN(2,6,23) 3335 3328 static int vbsf_vmlog_fault(struct vm_area_struct *vma, struct vm_fault *vmf) 3336 3329 { 3337 3330 int rc; 3338 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10,0)3331 # if RTLNX_VER_MIN(4,10,0) 3339 3332 SFLOGFLOW(("vbsf_vmlog_fault: vma=%p vmf=%p flags=%#x addr=%p\n", vma, vmf, vmf->flags, vmf->address)); 3340 3333 # else … … 3349 3342 3350 3343 /* 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) 3353 3346 static struct page *vbsf_vmlog_nopage(struct vm_area_struct *vma, unsigned long address, int *type) 3354 3347 { … … 3372 3365 3373 3366 /* 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) 3375 3368 static vm_fault_t vbsf_vmlog_page_mkwrite(struct vm_fault *vmf) 3376 3369 { … … 3381 3374 return rc; 3382 3375 } 3383 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,30)3376 # elif RTLNX_VER_MIN(2,6,30) 3384 3377 static int vbsf_vmlog_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) 3385 3378 { 3386 3379 int rc; 3387 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10,0)3380 # if RTLNX_VER_MIN(4,10,0) 3388 3381 SFLOGFLOW(("vbsf_vmlog_page_mkwrite: vma=%p vmf=%p flags=%#x addr=%p\n", vma, vmf, vmf->flags, vmf->address)); 3389 3382 # else … … 3394 3387 return rc; 3395 3388 } 3396 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,18)3389 # elif RTLNX_VER_MIN(2,6,18) 3397 3390 static int vbsf_vmlog_page_mkwrite(struct vm_area_struct *vma, struct page *page) 3398 3391 { … … 3407 3400 3408 3401 /* 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) 3410 3403 static void vbsf_vmlog_map_pages(struct vm_fault *vmf, pgoff_t start, pgoff_t end) 3411 3404 { … … 3414 3407 SFLOGFLOW(("vbsf_vmlog_map_pages: returns\n")); 3415 3408 } 3416 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8,0)3409 # elif RTLNX_VER_MIN(4,8,0) 3417 3410 static void vbsf_vmlog_map_pages(struct fault_env *fenv, pgoff_t start, pgoff_t end) 3418 3411 { … … 3421 3414 SFLOGFLOW(("vbsf_vmlog_map_pages: returns\n")); 3422 3415 } 3423 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15,0)3416 # elif RTLNX_VER_MIN(3,15,0) 3424 3417 static void vbsf_vmlog_map_pages(struct vm_area_struct *vma, struct vm_fault *vmf) 3425 3418 { … … 3433 3426 /** Overload template. */ 3434 3427 static 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) 3436 3429 .fault = vbsf_vmlog_fault, 3437 3430 # endif 3438 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 25)3431 # if RTLNX_VER_MAX(2,6,26) 3439 3432 .nopage = vbsf_vmlog_nopage, 3440 3433 # endif 3441 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,18)3434 # if RTLNX_VER_MIN(2,6,18) 3442 3435 .page_mkwrite = vbsf_vmlog_page_mkwrite, 3443 3436 # endif 3444 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15,0)3437 # if RTLNX_VER_MIN(3,15,0) 3445 3438 .map_pages = vbsf_vmlog_map_pages, 3446 3439 # endif … … 3499 3492 .read = vbsf_reg_read, 3500 3493 .write = vbsf_reg_write, 3501 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16,0)3494 #if RTLNX_VER_MIN(3,16,0) 3502 3495 .read_iter = vbsf_reg_read_iter, 3503 3496 .write_iter = vbsf_reg_write_iter, 3504 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,19)3497 #elif RTLNX_VER_MIN(2,6,19) 3505 3498 .aio_read = vbsf_reg_aio_read, 3506 3499 .aio_write = vbsf_reg_aio_write, … … 3512 3505 .mmap = generic_file_mmap, 3513 3506 #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) 3515 3508 .splice_read = vbsf_splice_read, 3516 3509 #endif 3517 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16,0)3510 #if RTLNX_VER_MIN(3,16,0) 3518 3511 .splice_write = iter_file_splice_write, 3519 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,17)3512 #elif RTLNX_VER_MIN(2,6,17) 3520 3513 .splice_write = vbsf_splice_write, 3521 3514 #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) 3523 3516 .sendfile = vbsf_reg_sendfile, 3524 3517 #endif 3525 3518 .llseek = vbsf_reg_llseek, 3526 3519 .fsync = vbsf_reg_fsync, 3527 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5,0)3520 #if RTLNX_VER_MIN(4,5,0) 3528 3521 .copy_file_range = vbsf_reg_copy_file_range, 3529 3522 #endif … … 3535 3528 */ 3536 3529 struct inode_operations vbsf_reg_iops = { 3537 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,18)3530 #if RTLNX_VER_MIN(2,5,18) 3538 3531 .getattr = vbsf_inode_getattr, 3539 3532 #else … … 3621 3614 * fashion. 3622 3615 */ 3623 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,52)3616 #if RTLNX_VER_MIN(2,5,52) 3624 3617 static int vbsf_writepage(struct page *page, struct writeback_control *wbc) 3625 3618 #else … … 3698 3691 3699 3692 3700 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,24)3693 #if RTLNX_VER_MIN(2,6,24) 3701 3694 /** 3702 3695 * Called when writing thru the page cache (which we shouldn't be doing). … … 3724 3717 3725 3718 3726 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,10)3719 #if RTLNX_VER_MIN(2,4,10) 3727 3720 3728 3721 # ifdef VBOX_UEK … … 3774 3767 .writepage = vbsf_writepage, 3775 3768 /** @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) 3777 3770 .set_page_dirty = __set_page_dirty_buffers, 3778 3771 #endif 3779 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,24)3772 #if RTLNX_VER_MIN(2,6,24) 3780 3773 .write_begin = vbsf_write_begin, 3781 3774 .write_end = simple_write_end, 3782 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,45)3775 #elif RTLNX_VER_MIN(2,5,45) 3783 3776 .prepare_write = simple_prepare_write, 3784 3777 .commit_write = simple_commit_write, 3785 3778 #endif 3786 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,10)3779 #if RTLNX_VER_MIN(2,4,10) 3787 3780 .direct_IO = vbsf_direct_IO, 3788 3781 #endif -
trunk/src/VBox/Additions/linux/sharedfolders/utils.c
r82968 r85698 51 51 52 52 while (in_bound_len) { 53 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,31)53 #if RTLNX_VER_MIN(2,6,31) 54 54 unicode_t uni; 55 55 int cbInEnc = utf8_to_utf32(in, in_bound_len, &uni); … … 112 112 if (cbNlsCodepoint >= 0) { 113 113 char achTmp[16]; 114 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,31)114 #if RTLNX_VER_MIN(2,6,31) 115 115 int cbUtf8Codepoint = utf32_to_utf8(uc, achTmp, sizeof(achTmp)); 116 116 #else … … 145 145 int const cbNlsCodepoint = pSuperInfo->nls->char2uni(&pszNls[offNls], cchNls - offNls, &uc); 146 146 if (cbNlsCodepoint >= 0) { 147 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,31)147 #if RTLNX_VER_MIN(2,6,31) 148 148 int cbUtf8Codepoint = utf32_to_utf8(uc, pchDst, cchUtf8); 149 149 #else … … 215 215 * Convert from VBox to linux time. 216 216 */ 217 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,0)217 #if RTLNX_VER_MAX(2,6,0) 218 218 DECLINLINE(void) vbsf_time_to_linux(time_t *pLinuxDst, PCRTTIMESPEC pVBoxSrc) 219 219 { … … 223 223 } 224 224 #else /* >= 2.6.0 */ 225 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18,0)225 # if RTLNX_VER_MAX(4,18,0) 226 226 DECLINLINE(void) vbsf_time_to_linux(struct timespec *pLinuxDst, PCRTTIMESPEC pVBoxSrc) 227 227 # else … … 239 239 * Convert from linux to VBox time. 240 240 */ 241 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,0)241 #if RTLNX_VER_MAX(2,6,0) 242 242 DECLINLINE(void) vbsf_time_to_vbox(PRTTIMESPEC pVBoxDst, time_t *pLinuxSrc) 243 243 { … … 245 245 } 246 246 #else /* >= 2.6.0 */ 247 # if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18,0)247 # if RTLNX_VER_MAX(4,18,0) 248 248 DECLINLINE(void) vbsf_time_to_vbox(PRTTIMESPEC pVBoxDst, struct timespec const *pLinuxSrc) 249 249 # else … … 327 327 inode->i_fop = &vbsf_reg_fops; 328 328 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) 331 330 inode->i_mapping->backing_dev_info = &pSuperInfo->bdi; /* This is needed for mmap. */ 332 331 #endif … … 334 333 } 335 334 336 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5,0)335 #if RTLNX_VER_MIN(3,5,0) 337 336 inode->i_uid = make_kuid(current_user_ns(), pSuperInfo->uid); 338 337 inode->i_gid = make_kgid(current_user_ns(), pSuperInfo->gid); … … 343 342 344 343 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) 346 345 inode->i_blksize = 4096; 347 346 #endif 348 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,11)347 #if RTLNX_VER_MIN(2,4,11) 349 348 inode->i_blkbits = 12; 350 349 #endif … … 374 373 TRACE(); 375 374 376 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5,0)375 #if RTLNX_VER_MIN(4,5,0) 377 376 if (!fInodeLocked) 378 377 inode_lock(pInode); … … 402 401 vbsf_init_inode(pInode, pInodeInfo, pObjInfo, pSuperInfo); 403 402 404 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5,0)403 #if RTLNX_VER_MIN(4,5,0) 405 404 if (!fInodeLocked) 406 405 inode_unlock(pInode); … … 467 466 if (mapping && mapping->nrpages > 0) { 468 467 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) 470 469 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) 472 471 invalidate_inode_pages(mapping); 473 472 #else … … 487 486 * Done. 488 487 */ 489 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5,0)488 #if RTLNX_VER_MIN(4,5,0) 490 489 if (!fInodeLocked) 491 490 inode_unlock(pInode); … … 627 626 628 627 629 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5,18)628 #if RTLNX_VER_MAX(2,5,18) 630 629 /** 631 630 * Revalidate an inode for 2.4. … … 700 699 has inode at all) from these new attributes we derive [kstat] via 701 700 [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) 705 704 int vbsf_inode_getattr(const struct path *path, struct kstat *kstat, u32 request_mask, unsigned int flags) 706 705 # else … … 709 708 { 710 709 int rc; 711 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11,0)710 # if RTLNX_VER_MIN(4,11,0) 712 711 struct dentry *dentry = path->dentry; 713 712 # endif 714 713 715 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11,0)714 # if RTLNX_VER_MIN(4,11,0) 716 715 SFLOGFLOW(("vbsf_inode_getattr: dentry=%p request_mask=%#x flags=%#x\n", dentry, request_mask, flags)); 717 716 # else … … 719 718 # endif 720 719 721 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11,0)720 # if RTLNX_VER_MIN(4,11,0) 722 721 /* 723 722 * With the introduction of statx() userland can control whether we … … 745 744 746 745 /* Add birth time. */ 747 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11,0)746 # if RTLNX_VER_MIN(4,11,0) 748 747 if (dentry->d_inode) { 749 748 struct vbsf_inode_info *pInodeInfo = VBSF_GET_INODE_INFO(dentry->d_inode); … … 807 806 */ 808 807 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)) 810 809 rc = setattr_prepare(dentry, iattr); 811 810 #else … … 818 817 */ 819 818 unsigned fAttrs = iattr->ia_valid; 820 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,15)819 #if RTLNX_VER_MIN(2,6,15) 821 820 fAttrs &= ~ATTR_FILE; 822 821 #endif 823 822 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) 825 824 || (fAttrs & (ATTR_OPEN | ATTR_SIZE)) == (ATTR_OPEN | ATTR_SIZE) 826 825 #endif … … 1067 1066 in += nb; 1068 1067 1069 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,31)1068 #if RTLNX_VER_MIN(2,6,31) 1070 1069 nb = utf32_to_utf8(uni, out, out_bound_len); 1071 1070 #else … … 1113 1112 * @note Caller holds no relevant locks, just a dentry reference. 1114 1113 */ 1115 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6,0)1114 #if RTLNX_VER_MIN(3,6,0) 1116 1115 static 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) 1118 1117 static int vbsf_dentry_revalidate(struct dentry *dentry, struct nameidata *nd) 1119 1118 #else … … 1121 1120 #endif 1122 1121 { 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) 1124 1123 int const flags = nd ? nd->flags : 0; 1125 1124 #endif … … 1139 1138 * 1140 1139 */ 1141 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,38)1140 #if RTLNX_VER_MIN(2,6,38) 1142 1141 if (flags & LOOKUP_RCU) { 1143 1142 rc = -ECHILD; … … 1181 1180 * later point). 1182 1181 */ 1183 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,28)1182 #if RTLNX_VER_MIN(2,6,28) 1184 1183 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) 1186 1185 if (flags & LOOKUP_CREATE) 1187 1186 #else … … 1214 1213 1215 1214 /** For logging purposes only. */ 1216 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,38)1215 # if RTLNX_VER_MIN(2,6,38) 1217 1216 static int vbsf_dentry_delete(const struct dentry *pDirEntry) 1218 1217 # else … … 1224 1223 } 1225 1224 1226 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8,0)1225 # if RTLNX_VER_MIN(4,8,0) 1227 1226 /** For logging purposes only. */ 1228 1227 static int vbsf_dentry_init(struct dentry *pDirEntry) … … 1244 1243 #ifdef SFLOG_ENABLED 1245 1244 .d_delete = vbsf_dentry_delete, 1246 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8,0)1245 # if RTLNX_VER_MIN(4,8,0) 1247 1246 .d_init = vbsf_dentry_init, 1248 1247 # endif -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c
r85432 r85698 46 46 #include "revision-generated.h" 47 47 #include "product-generated.h" 48 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0,0)48 #if RTLNX_VER_MIN(5,0,0) 49 49 # 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) 51 51 # include <linux/mount.h> 52 52 #endif 53 53 #include <linux/seq_file.h> 54 54 #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) 56 56 # include <linux/vermagic.h> 57 57 #endif … … 356 356 { 357 357 int rc = 0; 358 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,0)358 #if RTLNX_VER_MIN(2,6,0) 359 359 /* Each new shared folder map gets a new uint64_t identifier, 360 360 * 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) 362 362 static uint64_t s_u64Sequence = 0; 363 363 uint64_t idSeqMine = ASMAtomicIncU64(&s_u64Sequence); … … 365 365 struct backing_dev_info *bdi; 366 366 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) 368 368 pSuperInfo->bdi_org = sb->s_bdi; 369 369 # endif 370 370 371 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12,0)371 # if RTLNX_VER_MIN(4,12,0) 372 372 rc = super_setup_bdi_name(sb, "vboxsf-%llu", (unsigned long long)idSeqMine); 373 373 if (!rc) … … 381 381 bdi->ra_pages = 0; /* No readahead */ 382 382 383 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,12)383 # if RTLNX_VER_MIN(2,6,12) 384 384 bdi->capabilities = 0 385 385 # ifdef BDI_CAP_MAP_DIRECT … … 399 399 # endif 400 400 # 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. 402 402 * Only tested successfully with 4.19. Maybe skip altogether? */ 403 403 | BDI_CAP_STRICTLIMIT; … … 414 414 # endif /* >= 2.6.12 */ 415 415 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) 417 417 rc = bdi_init(&pSuperInfo->bdi); 418 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,26)418 # if RTLNX_VER_MIN(2,6,26) 419 419 if (!rc) 420 420 rc = bdi_register(&pSuperInfo->bdi, NULL, "vboxsf-%llu", (unsigned long long)idSeqMine); … … 422 422 # endif /* 4.11.0 > version >= 2.6.24 */ 423 423 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) 425 425 if (!rc) 426 426 sb->s_bdi = bdi; … … 437 437 static void vbsf_done_backing_dev(struct super_block *sb, struct vbsf_super_info *pSuperInfo) 438 438 { 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) 440 440 bdi_destroy(&pSuperInfo->bdi); /* includes bdi_unregister() */ 441 441 442 442 /* Paranoia: Make sb->s_bdi not point at pSuperInfo->bdi, in case someone 443 443 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) 445 445 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) 447 447 sb->s_bdi = &noop_backing_dev_info; 448 448 # endif … … 491 491 * Note! ls -la does display '.' and '..' entries with st_ino == 0, so root is #1. 492 492 */ 493 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,25)493 #if RTLNX_VER_MIN(2,4,25) 494 494 struct inode *iroot = iget_locked(sb, 1); 495 495 #else … … 500 500 VBSF_SET_INODE_INFO(iroot, sf_i); 501 501 502 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,25)502 #if RTLNX_VER_MIN(2,4,25) 503 503 unlock_new_inode(iroot); 504 504 #endif … … 507 507 * Now make it a root inode. 508 508 */ 509 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4,0)509 #if RTLNX_VER_MIN(3,4,0) 510 510 sb->s_root = d_make_root(iroot); 511 511 #else … … 518 518 519 519 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 */ 521 521 iput(iroot); 522 522 #endif … … 582 582 sb->s_magic = 0xface; 583 583 sb->s_blocksize = 1024; 584 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,3)584 #if RTLNX_VER_MIN(2,4,3) 585 585 /* Required for seek/sendfile (see 'loff_t max' in fs/read_write.c / do_sendfile()). */ 586 586 # if defined MAX_LFS_FILESIZE … … 592 592 # endif 593 593 #endif 594 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,11)594 #if RTLNX_VER_MIN(2,6,11) 595 595 sb->s_time_gran = 1; /* This might be a little optimistic for windows hosts, where it should be 100. */ 596 596 #endif 597 597 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) 599 599 sb->s_d_op = &vbsf_dentry_ops; 600 600 #endif … … 629 629 * We must free the inode info structure here. 630 630 */ 631 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,36)631 #if RTLNX_VER_MIN(2,6,36) 632 632 static void vbsf_evict_inode(struct inode *inode) 633 633 #else … … 642 642 * Flush stuff. 643 643 */ 644 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,36)644 #if RTLNX_VER_MIN(2,6,36) 645 645 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) 647 647 clear_inode(inode); 648 648 # else … … 673 673 hence we can't do anything here, and let lookup/whatever with the 674 674 job to properly fill then [inode] */ 675 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,25)675 #if RTLNX_VER_MAX(2,6,25) 676 676 static void vbsf_read_inode(struct inode *inode) 677 677 { … … 696 696 * Get file system statistics. 697 697 */ 698 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,18)698 #if RTLNX_VER_MIN(2,6,18) 699 699 static 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) 701 701 static int vbsf_statfs(struct super_block *sb, struct kstatfs *stat) 702 702 #else … … 704 704 #endif 705 705 { 706 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,18)706 #if RTLNX_VER_MIN(2,6,18) 707 707 struct super_block *sb = dentry->d_inode->i_sb; 708 708 #endif … … 716 716 stat->f_type = UINT32_C(0x786f4256); /* 'VBox' little endian */ 717 717 stat->f_bsize = pVolInfo->ulBytesPerAllocationUnit; 718 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,73)718 #if RTLNX_VER_MIN(2,5,73) 719 719 stat->f_frsize = pVolInfo->ulBytesPerAllocationUnit; 720 720 #endif … … 731 731 stat->f_fsid.val[1] = 0; 732 732 stat->f_namelen = 255; 733 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,36)733 #if RTLNX_VER_MIN(2,6,36) 734 734 stat->f_flags = 0; /* not valid */ 735 735 #endif … … 746 746 static int vbsf_remount_fs(struct super_block *sb, int *flags, char *data) 747 747 { 748 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,23)748 #if RTLNX_VER_MIN(2,4,23) 749 749 struct vbsf_super_info *pSuperInfo = pSuperInfo = VBSF_GET_SUPER_INFO(sb); 750 750 struct vbsf_inode_info *sf_i; … … 774 774 /*unlock_new_inode(iroot); */ 775 775 return 0; 776 #else /* LINUX_VERSION_CODE< 2.4.23 */776 #else /* < 2.4.23 */ 777 777 return -ENOSYS; 778 #endif /* LINUX_VERSION_CODE< 2.4.23 */778 #endif /* < 2.4.23 */ 779 779 } 780 780 … … 786 786 * the the 'szTag' option value it sets on its mount. 787 787 */ 788 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3,0)788 #if RTLNX_VER_MAX(3,3,0) 789 789 static int vbsf_show_options(struct seq_file *m, struct vfsmount *mnt) 790 790 #else … … 792 792 #endif 793 793 { 794 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3,0)794 #if RTLNX_VER_MAX(3,3,0) 795 795 struct super_block *sb = mnt->mnt_sb; 796 796 #else … … 845 845 */ 846 846 static 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) 848 848 .clear_inode = vbsf_clear_inode, 849 849 #else 850 850 .evict_inode = vbsf_evict_inode, 851 851 #endif 852 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,25)852 #if RTLNX_VER_MAX(2,6,25) 853 853 .read_inode = vbsf_read_inode, 854 854 #endif … … 865 865 *********************************************************************************************************************************/ 866 866 867 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,4)867 #if RTLNX_VER_MIN(2,5,4) 868 868 869 869 static int vbsf_read_super_26(struct super_block *sb, void *data, int flags) … … 879 879 } 880 880 881 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18) 881 # if RTLNX_VER_MIN(2,6,39) 882 static 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) 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 /* < 2.6.18 */ 882 894 static struct super_block *vbsf_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) 883 895 { … … 885 897 return get_sb_nodev(fs_type, flags, data, vbsf_read_super_26); 886 898 } 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 900 900 901 901 /** … … 905 905 .owner = THIS_MODULE, 906 906 .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 908 910 .get_sb = vbsf_get_sb, 909 # else910 .mount = sf_mount,911 911 # endif 912 912 .kill_sb = kill_anon_super 913 913 }; 914 914 915 #else /* LINUX_VERSION_CODE< 2.5.4 */915 #else /* < 2.5.4 */ 916 916 917 917 static struct super_block *vbsf_read_super_24(struct super_block *sb, void *data, int flags) … … 931 931 static DECLARE_FSTYPE(g_vboxsf_fs_type, "vboxsf", vbsf_read_super_24, 0); 932 932 933 #endif /* LINUX_VERSION_CODE< 2.5.4 */933 #endif /* < 2.5.4 */ 934 934 935 935 … … 1054 1054 * Module parameters. 1055 1055 */ 1056 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,52)1056 #if RTLNX_VER_MIN(2,5,52) 1057 1057 module_param_named(follow_symlinks, g_fFollowSymlinks, int, 0); 1058 1058 MODULE_PARM_DESC(follow_symlinks, -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h
r82968 r85698 46 46 #include <VBox/log.h> 47 47 48 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,0)48 #if RTLNX_VER_MIN(2,6,0) 49 49 # include <linux/backing-dev.h> 50 50 #endif … … 83 83 * inode compatibility glue. 84 84 */ 85 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,0)85 #if RTLNX_VER_MAX(2,6,0) 86 86 87 87 DECLINLINE(loff_t) i_size_read(struct inode *pInode) … … 99 99 #endif /* < 2.6.0 */ 100 100 101 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2,0) \101 #if RTLNX_VER_MAX(3,2,0) \ 102 102 && (!defined(RHEL_MAJOR) || RHEL_MAJOR != 6 || RHEL_MINOR < 10) 103 103 DECLINLINE(void) set_nlink(struct inode *pInode, unsigned int cLinks) … … 150 150 /** Mount tag for VBoxService automounter. @since 6.0 */ 151 151 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) 153 153 /** The backing device info structure. */ 154 154 struct backing_dev_info bdi; … … 160 160 /** The time to live for inode information in milliseconds, for /proc/mounts. */ 161 161 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) 163 163 /** 4.0 and 4.1 are missing noop_backing_dev_info export, so take down the 164 164 * initial value so we can restore it in vbsf_done_backing_dev(). (paranoia) */ … … 169 169 /* Following casts are here to prevent assignment of void * to 170 170 pointers of arbitrary type */ 171 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,0)171 #if RTLNX_VER_MAX(2,6,0) 172 172 # define VBSF_GET_SUPER_INFO(sb) ((struct vbsf_super_info *)(sb)->u.generic_sbp) 173 173 # define VBSF_SET_SUPER_INFO(sb, a_pSuperInfo) do { (sb)->u.generic_sbp = a_pSuperInfo; } while (0) … … 249 249 }; 250 250 251 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,19) || defined(KERNEL_FC6)251 #if RTLNX_VER_MIN(2,6,19) || defined(KERNEL_FC6) 252 252 /* FC6 kernel 2.6.18, vanilla kernel 2.6.19+ */ 253 253 # define VBSF_GET_INODE_INFO(i) ((struct vbsf_inode_info *) (i)->i_private) … … 265 265 extern int vbsf_inode_revalidate_worker(struct dentry *dentry, bool fForced, bool fInodeLocked); 266 266 extern 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) 269 269 extern int vbsf_inode_getattr(const struct path *path, struct kstat *kstat, u32 request_mask, unsigned int query_flags); 270 270 # else … … 420 420 421 421 /** 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) 423 423 # 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) 425 425 # define VBSF_GET_F_DENTRY(f) (f->f_path.dentry) 426 426 #else -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r85552 r85698 55 55 56 56 #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) 59 59 # include <generated/autoconf.h> 60 60 # else … … 65 65 # if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS) 66 66 # define MODVERSIONS 67 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5,71)67 # if RTLNX_VER_MAX(2,5,71) 68 68 # include <linux/modversions.h> 69 69 # endif 70 70 # endif 71 71 # ifndef KBUILD_STR 72 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,16)72 # if RTLNX_VER_MAX(2,6,16) 73 73 # define KBUILD_STR(s) s 74 74 # else … … 79 79 # include <linux/spinlock.h> 80 80 # include <linux/slab.h> 81 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27)81 # if RTLNX_VER_MIN(2,6,27) 82 82 # include <linux/semaphore.h> 83 83 # else /* older kernels */ -
trunk/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
r85505 r85698 47 47 48 48 /** @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) 50 50 # include <iprt/power.h> 51 51 # define VBOX_WITH_SUSPEND_NOTIFICATION … … 57 57 # include <linux/platform_device.h> 58 58 #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) 60 60 # define SUPDRV_LINUX_HAS_SAFE_MSR_API 61 61 # include <asm/msr.h> … … 72 72 /* check kernel version */ 73 73 # ifndef SUPDRV_AGNOSTIC 74 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,0)74 # if RTLNX_VER_MAX(2,6,0) 75 75 # error Unsupported kernel version! 76 76 # endif … … 112 112 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 113 113 static int VBoxDrvProbe(struct platform_device *pDev); 114 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,30)114 # if RTLNX_VER_MIN(2,6,30) 115 115 static int VBoxDrvSuspend(struct device *pDev); 116 116 static int VBoxDrvResume(struct device *pDev); … … 140 140 #define DEVICE_NAME_USR "vboxdrvu" 141 141 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) 143 143 /** 144 144 * Memory for the executable memory heap (in IPRT). … … 203 203 name: DEVICE_NAME_SYS, 204 204 fops: &gFileOpsVBoxDrvSys, 205 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)205 # if RTLNX_VER_MAX(2,6,18) 206 206 devfs_name: DEVICE_NAME_SYS, 207 207 # endif … … 213 213 name: DEVICE_NAME_USR, 214 214 fops: &gFileOpsVBoxDrvUsr, 215 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)215 # if RTLNX_VER_MAX(2,6,18) 216 216 devfs_name: DEVICE_NAME_USR, 217 217 # endif … … 220 220 221 221 #ifdef VBOX_WITH_SUSPEND_NOTIFICATION 222 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,30)222 # if RTLNX_VER_MIN(2,6,30) 223 223 static struct dev_pm_ops gPlatformPMOps = 224 224 { … … 233 233 { 234 234 .probe = VBoxDrvProbe, 235 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,30)235 # if RTLNX_VER_MAX(2,6,30) 236 236 .suspend = VBoxDrvSuspend, 237 237 .resume = VBoxDrvResume, … … 241 241 { 242 242 .name = "vboxdrv", 243 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,30)243 # if RTLNX_VER_MIN(2,6,30) 244 244 .pm = &gPlatformPMOps, 245 245 # endif … … 260 260 DECLINLINE(RTUID) vboxdrvLinuxUid(void) 261 261 { 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) 264 264 return from_kuid(current_user_ns(), current->cred->uid); 265 265 # else … … 273 273 DECLINLINE(RTGID) vboxdrvLinuxGid(void) 274 274 { 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) 277 277 return from_kgid(current_user_ns(), current->cred->gid); 278 278 # else … … 286 286 DECLINLINE(RTUID) vboxdrvLinuxEuid(void) 287 287 { 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) 290 290 return from_kuid(current_user_ns(), current->cred->euid); 291 291 # else … … 332 332 if (RT_SUCCESS(rc)) 333 333 { 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) 335 335 # ifdef VBOX_WITH_TEXT_MODMEM_HACK 336 336 set_memory_x(&g_abExecMemory[0], sizeof(g_abExecMemory) / PAGE_SIZE); … … 516 516 * Ignored. 517 517 */ 518 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,30) && !defined(DOXYGEN_RUNNING)518 # if RTLNX_VER_MIN(2,6,30) && !defined(DOXYGEN_RUNNING) 519 519 static int VBoxDrvSuspend(struct device *pDev) 520 520 # else … … 531 531 * @param pDev Pointer to the platform device. 532 532 */ 533 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,30)533 # if RTLNX_VER_MIN(2,6,30) 534 534 static int VBoxDrvResume(struct device *pDev) 535 535 # else … … 757 757 RTCCUINTREG VBOXCALL supdrvOSChangeCR4(RTCCUINTREG fOrMask, RTCCUINTREG fAndMask) 758 758 { 759 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8,0)759 #if RTLNX_VER_MIN(5,8,0) 760 760 RTCCUINTREG const uOld = __read_cr4(); 761 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20,0)761 #elif RTLNX_VER_MIN(3,20,0) 762 762 RTCCUINTREG const uOld = this_cpu_read(cpu_tlbstate.cr4); 763 763 #else … … 767 767 if (uNew != uOld) 768 768 { 769 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8,0)769 #if RTLNX_VER_MIN(5,8,0) 770 770 ASMSetCR4(uNew); 771 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20,0)771 #elif RTLNX_VER_MIN(3,20,0) 772 772 this_cpu_write(cpu_tlbstate.cr4, uNew); 773 773 __write_cr4(uNew); … … 1121 1121 1122 1122 /* Nobody waiting and no exit function. */ 1123 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13,0)1123 # if RTLNX_VER_MAX(3,13,0) 1124 1124 pMyMod->waiter = NULL; 1125 1125 # endif … … 1128 1128 /* References, very important as we must not allow the module 1129 1129 to be unloaded using rmmod. */ 1130 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19,0)1130 # if RTLNX_VER_MIN(3,19,0) 1131 1131 atomic_set(&pMyMod->refcnt, 42); 1132 1132 # else … … 1213 1213 mutex_unlock(&module_mutex); 1214 1214 1215 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19,0)1215 # if RTLNX_VER_MAX(3,19,0) 1216 1216 free_percpu(pMyMod->refptr); 1217 1217 # endif … … 1432 1432 fFlags |= SUPKERNELFEATURES_GDT_READ_ONLY; 1433 1433 #endif 1434 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12,0)1434 #if RTLNX_VER_MIN(4,12,0) 1435 1435 fFlags |= SUPKERNELFEATURES_GDT_NEED_WRITABLE; 1436 1436 #endif … … 1447 1447 int VBOXCALL supdrvOSGetCurrentGdtRw(RTHCUINTPTR *pGdtRw) 1448 1448 { 1449 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12,0)1449 #if RTLNX_VER_MIN(4,12,0) 1450 1450 *pGdtRw = (RTHCUINTPTR)get_current_gdt_rw(); 1451 1451 return VINF_SUCCESS; -
trunk/src/VBox/HostDrivers/Support/linux/files_vboxdrv
r85523 r85698 73 73 ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \ 74 74 ${PATH_ROOT}/include/iprt/x86.h=>include/iprt/x86.h \ 75 ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \ 75 76 ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \ 76 77 ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \ -
trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c
r82968 r85698 76 76 static int VBoxNetAdpLinuxOpen(struct inode *pInode, struct file *pFilp); 77 77 static 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) 79 79 static int VBoxNetAdpLinuxIOCtl(struct inode *pInode, struct file *pFilp, 80 80 unsigned int uCmd, unsigned long ulArg); 81 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)*/81 #else /* >= 2,6,36 */ 82 82 static long VBoxNetAdpLinuxIOCtlUnlocked(struct file *pFilp, 83 83 unsigned int uCmd, unsigned long ulArg); 84 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)*/84 #endif /* >= 2,6,36 */ 85 85 86 86 static 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) 88 88 static 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 */ 90 90 static 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 */ 92 92 93 93 … … 113 113 open: VBoxNetAdpLinuxOpen, 114 114 release: VBoxNetAdpLinuxClose, 115 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,36)115 #if RTLNX_VER_MAX(2,6,36) 116 116 ioctl: VBoxNetAdpLinuxIOCtl, 117 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,36) */117 #else /* RTLNX_VER_MIN(2,6,36) */ 118 118 unlocked_ioctl: VBoxNetAdpLinuxIOCtlUnlocked, 119 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,36) */119 #endif /* RTLNX_VER_MIN(2,6,36) */ 120 120 }; 121 121 … … 126 126 name: VBOXNETADP_CTL_DEV_NAME, 127 127 fops: &gFileOpsVBoxNetAdp, 128 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)128 # if RTLNX_VER_MAX(2,6,18) 129 129 devfs_name: VBOXNETADP_CTL_DEV_NAME 130 130 # endif 131 131 }; 132 132 133 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,19)133 # if RTLNX_VER_MIN(2,6,19) 134 134 static const struct ethtool_ops gEthToolOpsVBoxNetAdp = 135 135 # else … … 138 138 { 139 139 .get_drvinfo = vboxNetAdpEthGetDrvinfo, 140 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20,0)140 # if RTLNX_VER_MIN(4,20,0) 141 141 .get_link_ksettings = vboxNetAdpEthGetLinkSettings, 142 # else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */142 # else 143 143 .get_settings = vboxNetAdpEthGetSettings, 144 # endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0) */144 # endif 145 145 .get_link = ethtool_op_get_link, 146 146 }; … … 174 174 pPriv->Stats.tx_packets++; 175 175 pPriv->Stats.tx_bytes += pSkb->len; 176 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,31)176 #if RTLNX_VER_MAX(2,6,31) 177 177 /* Update transmission time stamp. */ 178 178 pNetDev->trans_start = jiffies; … … 214 214 215 215 216 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20,0)216 # if RTLNX_VER_MIN(4,20,0) 217 217 /* ethtool_ops::get_link_ksettings */ 218 218 static int vboxNetAdpEthGetLinkSettings(struct net_device *pNetDev, struct ethtool_link_ksettings *pLinkSettings) … … 230 230 return 0; 231 231 } 232 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 20,0) */232 #else /* RTLNX_VER_MAX(4,20,0) */ 233 233 /* ethtool_ops::get_settings */ 234 234 static int vboxNetAdpEthGetSettings(struct net_device *pNetDev, struct ethtool_cmd *cmd) … … 236 236 cmd->supported = 0; 237 237 cmd->advertising = 0; 238 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27)238 #if RTLNX_VER_MIN(2,6,27) 239 239 ethtool_cmd_speed_set(cmd, SPEED_10); 240 240 #else … … 250 250 return 0; 251 251 } 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) 256 256 static const struct net_device_ops vboxNetAdpNetdevOps = { 257 257 .ndo_open = vboxNetAdpLinuxOpen, … … 267 267 268 268 ether_setup(pNetDev); 269 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29)269 #if RTLNX_VER_MIN(2,6,29) 270 270 pNetDev->netdev_ops = &vboxNetAdpNetdevOps; 271 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,29) */271 #else /* RTLNX_VER_MAX(2,6,29) */ 272 272 pNetDev->open = vboxNetAdpLinuxOpen; 273 273 pNetDev->stop = vboxNetAdpLinuxStop; 274 274 pNetDev->hard_start_xmit = vboxNetAdpLinuxXmit; 275 275 pNetDev->get_stats = vboxNetAdpLinuxGetStats; 276 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,29) */276 #endif /* RTLNX_VER_MAX(2,6,29) */ 277 277 278 278 pNetDev->ethtool_ops = &gEthToolOpsVBoxNetAdp; … … 291 291 pNetDev = alloc_netdev(sizeof(VBOXNETADPPRIV), 292 292 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) 294 294 NET_NAME_UNKNOWN, 295 295 #endif … … 391 391 * @param ulArg The argument specified to ioctl(). 392 392 */ 393 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,36)393 #if RTLNX_VER_MAX(2,6,36) 394 394 static int VBoxNetAdpLinuxIOCtl(struct inode *pInode, struct file *pFilp, 395 395 unsigned int uCmd, unsigned long ulArg) 396 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,36) */396 #else /* RTLNX_VER_MIN(2,6,36) */ 397 397 static long VBoxNetAdpLinuxIOCtlUnlocked(struct file *pFilp, 398 398 unsigned int uCmd, unsigned long ulArg) 399 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,36) */399 #endif /* RTLNX_VER_MIN(2,6,36) */ 400 400 { 401 401 VBOXNETADPREQ Req; -
trunk/src/VBox/HostDrivers/VBoxNetAdp/linux/files_vboxnetadp
r82968 r85698 66 66 ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \ 67 67 ${PATH_ROOT}/include/iprt/x86.h=>include/iprt/x86.h \ 68 ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \ 68 69 ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \ 69 70 ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \ -
trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
r85588 r85698 35 35 #include "revision-generated.h" 36 36 #include "product-generated.h" 37 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,24)37 #if RTLNX_VER_MIN(2,6,24) 38 38 #include <linux/nsproxy.h> 39 39 #endif … … 46 46 #include <linux/ip.h> 47 47 #include <linux/if_vlan.h> 48 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5,0)48 #if RTLNX_VER_MIN(4,5,0) 49 49 #include <uapi/linux/pkt_cls.h> 50 50 #endif … … 90 90 #endif 91 91 92 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11,0)92 #if RTLNX_VER_MIN(3,11,0) 93 93 # define VBOX_NETDEV_NOTIFIER_INFO_TO_DEV(ptr) netdev_notifier_info_to_dev(ptr) 94 94 #else … … 96 96 #endif 97 97 98 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5,0)98 #if RTLNX_VER_MIN(3,5,0) 99 99 # define VBOX_SKB_KMAP_FRAG(frag) kmap_atomic(skb_frag_page(frag)) 100 100 # define VBOX_SKB_KUNMAP_FRAG(vaddr) kunmap_atomic(vaddr) 101 101 #else 102 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2,0)102 # if RTLNX_VER_MIN(3,2,0) 103 103 # define VBOX_SKB_KMAP_FRAG(frag) kmap_atomic(skb_frag_page(frag), KM_SKB_DATA_SOFTIRQ) 104 104 # define VBOX_SKB_KUNMAP_FRAG(vaddr) kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ) … … 109 109 #endif 110 110 111 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,34)111 #if RTLNX_VER_MIN(2,6,34) 112 112 # define VBOX_NETDEV_NAME(dev) netdev_name(dev) 113 113 #else … … 115 115 #endif 116 116 117 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,25)117 #if RTLNX_VER_MIN(2,6,25) 118 118 # define VBOX_IPV4_IS_LOOPBACK(addr) ipv4_is_loopback(addr) 119 119 # define VBOX_IPV4_IS_LINKLOCAL_169(addr) ipv4_is_linklocal_169(addr) … … 123 123 #endif 124 124 125 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,22)125 #if RTLNX_VER_MIN(2,6,22) 126 126 # define VBOX_SKB_RESET_NETWORK_HDR(skb) skb_reset_network_header(skb) 127 127 # define VBOX_SKB_RESET_MAC_HDR(skb) skb_reset_mac_header(skb) … … 133 133 #endif 134 134 135 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,19)135 #if RTLNX_VER_MIN(2,6,19) 136 136 # define VBOX_SKB_CHECKSUM_HELP(skb) skb_checksum_help(skb) 137 137 #else 138 138 # define CHECKSUM_PARTIAL CHECKSUM_HW 139 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,10)139 # if RTLNX_VER_MIN(2,6,10) 140 140 # define VBOX_SKB_CHECKSUM_HELP(skb) skb_checksum_help(skb, 0) 141 141 # else 142 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,7)142 # if RTLNX_VER_MIN(2,6,7) 143 143 # define VBOX_SKB_CHECKSUM_HELP(skb) skb_checksum_help(&skb, 0) 144 144 # else … … 151 151 #endif 152 152 153 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20,0)153 #if RTLNX_VER_MIN(3,20,0) 154 154 # define VBOX_HAVE_SKB_VLAN 155 155 #else … … 177 177 #endif 178 178 179 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,18)179 #if RTLNX_VER_MIN(2,6,18) 180 180 181 181 /** Indicates that the linux kernel may send us GSO frames. */ … … 196 196 # define VBOXNETFLT_WITH_GSO_RECV 1 197 197 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) 201 201 /** This enables or disables handling of GSO frames coming from the wire (GRO). */ 202 202 # define VBOXNETFLT_WITH_GRO 1 … … 246 246 247 247 248 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,12) && defined(LOG_ENABLED)248 #if RTLNX_VER_MAX(2,6,12) && defined(LOG_ENABLED) 249 249 unsigned dev_get_flags(const struct net_device *dev) 250 250 { … … 262 262 return flags; 263 263 } 264 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,12) */264 #endif /* RTLNX_VER_MAX(2,6,12) */ 265 265 266 266 … … 344 344 #ifdef VBOXNETFLT_WITH_HOST2WIRE_FILTER 345 345 346 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,29)346 # if RTLNX_VER_MAX(2,6,29) 347 347 348 348 # include <linux/ethtool.h> … … 352 352 # define OVR_XMIT pfnStartXmit 353 353 354 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29) */354 # else /* RTLNX_VER_MIN(2,6,29) */ 355 355 356 356 typedef struct net_device_ops OVR_OPSTYPE; … … 358 358 # define OVR_XMIT pOrgOps->ndo_start_xmit 359 359 360 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29) */360 # endif /* RTLNX_VER_MIN(2,6,29) */ 361 361 362 362 /** … … 379 379 /** Pointer to the original ops. */ 380 380 OVR_OPSTYPE const *pOrgOps; 381 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,29)381 # if RTLNX_VER_MAX(2,6,29) 382 382 /** Pointer to the original hard_start_xmit function. */ 383 383 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) */ 385 385 /** Pointer to the net filter instance. */ 386 386 PVBOXNETFLTINS pVBoxNetFlt; … … 419 419 if ( !VALID_PTR(pOverride) 420 420 || pOverride->u32Magic != VBOXNETDEVICEOPSOVERRIDE_MAGIC 421 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29)421 # if RTLNX_VER_MIN(2,6,29) 422 422 || !VALID_PTR(pOverride->pOrgOps) 423 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29) */423 # endif /* RTLNX_VER_MIN(2,6,29) */ 424 424 ) 425 425 { … … 479 479 pOverride->pOrgOps = pDev->OVR_OPS; 480 480 pOverride->Ops = *pDev->OVR_OPS; 481 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,29)481 # if RTLNX_VER_MAX(2,6,29) 482 482 pOverride->pfnStartXmit = pDev->hard_start_xmit; 483 # else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29) */483 # else /* RTLNX_VER_MIN(2,6,29) */ 484 484 pOverride->Ops.ndo_start_xmit = vboxNetFltLinuxStartXmitFilter; 485 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29) */485 # endif /* RTLNX_VER_MIN(2,6,29) */ 486 486 pOverride->u32Magic = VBOXNETDEVICEOPSOVERRIDE_MAGIC; 487 487 pOverride->cTotal = 0; … … 491 491 RTSpinlockAcquire(pThis->hSpinlock); /* (this isn't necessary, but so what) */ 492 492 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) 494 494 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) */ 496 496 RTSpinlockRelease(pThis->hSpinlock); 497 497 } … … 519 519 ) 520 520 { 521 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,29)521 # if RTLNX_VER_MAX(2,6,29) 522 522 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) */ 524 524 ASMAtomicWritePtr((void const * volatile *)&pDev->OVR_OPS, pOverride->pOrgOps); 525 525 ASMAtomicWriteU32(&pOverride->u32Magic, 0); … … 566 566 Log(("vboxNetFltLinuxRetainNetDev: Device %p(%s) retained. ref=%d\n", 567 567 pDev, pDev->name, 568 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,37)568 #if RTLNX_VER_MIN(2,6,37) 569 569 netdev_refcnt_read(pDev) 570 570 #else … … 602 602 Log(("vboxNetFltLinuxReleaseNetDev: Device %p(%s) released. ref=%d\n", 603 603 pDev, pDev->name, 604 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,37)604 #if RTLNX_VER_MIN(2,6,37) 605 605 netdev_refcnt_read(pDev) 606 606 #else … … 773 773 Assert(skb_headlen(pPkt) >= pSG->GsoCtx.cbHdrsTotal); 774 774 pPkt->ip_summed = CHECKSUM_PARTIAL; 775 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,22)775 # if RTLNX_VER_MIN(2,6,22) 776 776 pPkt->csum_start = skb_headroom(pPkt) + pSG->GsoCtx.offHdr2; 777 777 if (fGsoType & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) … … 817 817 DECLINLINE(unsigned) vboxNetFltLinuxGetChecksumStartOffset(struct sk_buff *pBuf) 818 818 { 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 820 824 unsigned char *pTransportHdr = pBuf->h.raw; 821 # if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18)825 # if RTLNX_VER_MAX(2,6,19) 822 826 /* 823 827 * Try to work around the problem with CentOS 4.7 and 5.2 (2.6.9 … … 828 832 if (pBuf->h.raw == pBuf->nh.raw && pBuf->protocol == htons(ETH_P_IP)) 829 833 pTransportHdr = pBuf->nh.raw + pBuf->nh.iph->ihl * 4; 830 # endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18) */834 # endif 831 835 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 839 837 } 840 838 … … 867 865 unsigned cbProduced = 0; 868 866 869 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27)867 # if RTLNX_VER_MIN(2,6,27) 870 868 /* Restore VLAN tag stripped by host hardware */ 871 869 if (vlan_tx_tag_present(pBuf)) … … 882 880 cbProduced += VLAN_ETH_HLEN; 883 881 } 884 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27) */882 # endif /* RTLNX_VER_MIN(2,6,27) */ 885 883 886 884 if (pBuf->ip_summed == CHECKSUM_PARTIAL && pBuf->pkt_type == PACKET_OUTGOING) … … 931 929 { 932 930 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) 934 932 pSG->aSegs[iSeg].cb = pFrag->bv_len; 935 933 pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->bv_offset; … … 952 950 { 953 951 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) 955 953 pSG->aSegs[iSeg].cb = pFrag->bv_len; 956 954 pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->bv_offset; … … 1027 1025 * @returns 0 or EJUSTRETURN - this is probably copy & pastry and thus wrong. 1028 1026 */ 1029 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,14)1027 #if RTLNX_VER_MIN(2,6,14) 1030 1028 static int vboxNetFltLinuxPacketHandler(struct sk_buff *pBuf, 1031 1029 struct net_device *pSkbDev, … … 1042 1040 LogFlow(("vboxNetFltLinuxPacketHandler: pBuf=%p pSkbDev=%p pPacketType=%p\n", 1043 1041 pBuf, pSkbDev, pPacketType)); 1044 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,18)1042 #if RTLNX_VER_MIN(2,6,18) 1045 1043 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", 1046 1044 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) 1048 1046 Log6(("vboxNetFltLinuxPacketHandler: packet dump follows:\n%.*Rhxd\n", pBuf->len-pBuf->data_len, skb_mac_header(pBuf))); 1049 1047 # endif … … 1102 1100 /* Somehow skb_copy ignores mac_len */ 1103 1101 pBuf->mac_len = uMacLen; 1104 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27)1102 # if RTLNX_VER_MIN(2,6,27) 1105 1103 /* Restore VLAN tag stripped by host hardware */ 1106 1104 if (vlan_tx_tag_present(pBuf) && skb_headroom(pBuf) >= VLAN_ETH_HLEN) … … 1114 1112 pBuf->mac_len += VLAN_HLEN; 1115 1113 } 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) 1119 1117 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", 1120 1118 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) 1122 1120 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) */ 1125 1123 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", 1126 1124 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) */ 1128 1126 } 1129 1127 #endif /* !VBOXNETFLT_SG_SUPPORT */ … … 1162 1160 *pcbTemp = vboxNetFltLinuxGetChecksumStartOffset(pBuf) + VBOX_SKB_CSUM_OFFSET(pBuf) + sizeof(uint16_t); 1163 1161 } 1164 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27)1162 # if RTLNX_VER_MIN(2,6,27) 1165 1163 if (vlan_tx_tag_present(pBuf)) 1166 1164 { … … 1170 1168 *pcbTemp = VLAN_ETH_HLEN; 1171 1169 } 1172 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27) */1170 # endif /* RTLNX_VER_MIN(2,6,27) */ 1173 1171 if (*pcbTemp) 1174 1172 ++cSegs; … … 1554 1552 * skb_gso_segment does the following. Do we need to do it as well? 1555 1553 */ 1556 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,22)1554 # if RTLNX_VER_MIN(2,6,22) 1557 1555 skb_reset_mac_header(pBuf); 1558 1556 pBuf->mac_len = pBuf->network_header - pBuf->mac_header; … … 1604 1602 if (pBuf->ip_summed == CHECKSUM_PARTIAL && pBuf->pkt_type == PACKET_OUTGOING) 1605 1603 { 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 1607 1607 /* 1608 1608 * Try to work around the problem with CentOS 4.7 and 5.2 (2.6.9 … … 1614 1614 if (pBuf->h.raw == pBuf->nh.raw && pBuf->protocol == htons(ETH_P_IP)) 1615 1615 pBuf->h.raw = pBuf->nh.raw + pBuf->nh.iph->ihl * 4; 1616 #endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18) */1617 1616 int rc = VBOX_SKB_CHECKSUM_HELP(pBuf); 1618 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18)1619 1617 /* Restore the original (wrong) pointer. */ 1620 1618 pBuf->h.raw = tmp; 1621 #endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18) */ 1622 if (rc) { 1619 # endif 1620 if (rc) 1621 { 1623 1622 LogRel(("VBoxNetFlt: Failed to compute checksum, dropping the packet.\n")); 1624 1623 return; … … 1674 1673 * @param pWork The work queue. 1675 1674 */ 1676 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,20)1675 # if RTLNX_VER_MIN(2,6,20) 1677 1676 static void vboxNetFltLinuxXmitTask(struct work_struct *pWork) 1678 1677 # else … … 1791 1790 return true; 1792 1791 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 */ 1794 1793 return !strncmp(Info.driver, "tun", 4) 1795 1794 && !strncmp(Info.bus_info, "tap", 4); … … 1800 1799 } 1801 1800 1802 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,18)1801 #if RTLNX_VER_MAX(2,6,18) 1803 1802 DECLINLINE(void) netif_tx_lock_bh(struct net_device *pDev) 1804 1803 { … … 1853 1852 Log(("vboxNetFltLinuxAttachToInterface: Device %p(%s) retained. ref=%d\n", 1854 1853 pDev, pDev->name, 1855 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,37)1854 #if RTLNX_VER_MIN(2,6,37) 1856 1855 netdev_refcnt_read(pDev) 1857 1856 #else … … 1950 1949 Log(("vboxNetFltLinuxUnregisterDevice: Device %p(%s) released. ref=%d\n", 1951 1950 pDev, pDev->name, 1952 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,37)1951 #if RTLNX_VER_MIN(2,6,37) 1953 1952 netdev_refcnt_read(pDev) 1954 1953 #else … … 2061 2060 if (ulEventType == NETDEV_REGISTER) 2062 2061 { 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) 2065 2064 # define VBOX_DEV_NET(dev) dev_net(dev) 2066 2065 # define VBOX_NET_EQ(n1, n2) net_eq((n1), (n2)) … … 2133 2132 * IPv4 2134 2133 */ 2135 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,14)2134 #if RTLNX_VER_MIN(2,6,14) 2136 2135 in_dev = __in_dev_get_rtnl(dev); 2137 2136 #else … … 2168 2167 2169 2168 read_lock_bh(&in6_dev->lock); 2170 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,35)2169 #if RTLNX_VER_MIN(2,6,35) 2171 2170 list_for_each_entry(ifa, &in6_dev->addr_list, if_list) 2172 2171 #else … … 2472 2471 Log(("vboxNetFltOsDeleteInstance: Device %p(%s) released. ref=%d\n", 2473 2472 pDev, pDev->name, 2474 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,37)2473 #if RTLNX_VER_MIN(2,6,37) 2475 2474 netdev_refcnt_read(pDev) 2476 2475 #else … … 2574 2573 #ifndef VBOXNETFLT_LINUX_NO_XMIT_QUEUE 2575 2574 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) 2577 2576 INIT_WORK(&pThis->u.s.XmitTask, vboxNetFltLinuxXmitTask); 2578 2577 # else -
trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/files_vboxnetflt
r82968 r85698 65 65 ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \ 66 66 ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \ 67 ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \ 67 68 ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \ 68 69 ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \ -
trunk/src/VBox/HostDrivers/VBoxPci/VBoxPciInternal.h
r82968 r85698 38 38 #ifdef RT_OS_LINUX 39 39 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) 41 41 # define VBOX_WITH_IOMMU 42 42 #endif -
trunk/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c
r83471 r85698 48 48 # include <linux/intel-iommu.h> 49 49 # 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)) 52 52 # include <asm/amd_iommu.h> 53 53 # else 54 54 # include <linux/amd-iommu.h> 55 55 # endif 56 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2,0)56 # if RTLNX_VER_MAX(3,2,0) 57 57 # define IOMMU_PRESENT() iommu_found() 58 58 # define IOMMU_DOMAIN_ALLOC() iommu_domain_alloc() … … 87 87 88 88 89 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,20)89 #if RTLNX_VER_MIN(2,6,20) 90 90 # define PCI_DEV_GET(v,d,p) pci_get_device(v,d,p) 91 91 # 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) 93 93 /* assume the domain number to be zero - exactly the same assumption of 94 94 * pci_get_bus_and_slot() … … 165 165 if (request_module(PCI_STUB_MODULE) == 0) 166 166 { 167 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,30)167 # if RTLNX_VER_MIN(2,6,30) 168 168 /* find_module() is static before Linux 2.6.30 */ 169 169 mutex_lock(&module_mutex); … … 320 320 if (RT_LIKELY(pIns->pPciDev)) 321 321 { 322 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,28)322 #if RTLNX_VER_MIN(2,6,28) 323 323 if (pci_reset_function(pIns->pPciDev)) 324 324 { … … 374 374 fs_save = get_fs(); 375 375 set_fs(KERNEL_DS); 376 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14,0)376 #if RTLNX_VER_MIN(4,14,0) 377 377 ret = kernel_write(file, data, size, &offset); 378 378 #else … … 448 448 int iCmdLen; 449 449 const int cMaxBuf = 128; 450 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29)450 #if RTLNX_VER_MIN(2,6,29) 451 451 const struct cred *pOldCreds; 452 452 struct cred *pNewCreds; … … 469 469 470 470 /* Somewhat ugly hack - override current credentials */ 471 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29)471 #if RTLNX_VER_MIN(2,6,29) 472 472 pNewCreds = prepare_creds(); 473 473 if (!pNewCreds) 474 474 goto done; 475 475 476 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5,0)476 # if RTLNX_VER_MIN(3,5,0) 477 477 pNewCreds->fsuid = GLOBAL_ROOT_UID; 478 478 # else … … 533 533 printk(KERN_DEBUG "vboxpci: cannot open %s\n", szFileBuf); 534 534 535 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29)535 #if RTLNX_VER_MIN(2,6,29) 536 536 revert_creds(pOldCreds); 537 537 put_cred(pNewCreds); … … 560 560 int iCmdLen; 561 561 const int cMaxBuf = 128; 562 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29)562 #if RTLNX_VER_MIN(2,6,29) 563 563 const struct cred *pOldCreds; 564 564 struct cred *pNewCreds; … … 586 586 587 587 /* Somewhat ugly hack - override current credentials */ 588 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29)588 #if RTLNX_VER_MIN(2,6,29) 589 589 pNewCreds = prepare_creds(); 590 590 if (!pNewCreds) 591 591 goto done; 592 592 593 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5,0)593 # if RTLNX_VER_MIN(3,5,0) 594 594 pNewCreds->fsuid = GLOBAL_ROOT_UID; 595 595 # else … … 627 627 printk(KERN_DEBUG "vboxpci: cannot open %s\n", szFileBuf); 628 628 629 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,29)629 #if RTLNX_VER_MIN(2,6,29) 630 630 revert_creds(pOldCreds); 631 631 put_cred(pNewCreds); … … 670 670 vbpci_printk(KERN_DEBUG, pPciDev, "%s\n", __func__); 671 671 672 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,1)672 #if RTLNX_VER_MIN(2,6,1) 673 673 if (pci_enable_msi(pPciDev) == 0) 674 674 pIns->fMsiUsed = true; … … 717 717 vboxPciLinuxDevUnregisterWithIommu(pIns); 718 718 719 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,1)719 #if RTLNX_VER_MIN(2,6,1) 720 720 if (pIns->fMsiUsed) 721 721 pci_disable_msi(pPciDev); … … 843 843 if (!rcLnx) 844 844 { 845 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,25)845 #if RTLNX_VER_MIN(2,6,25) 846 846 /* 847 847 * ioremap() defaults to no caching since the 2.6 kernels. … … 859 859 else 860 860 { 861 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,25)861 #if RTLNX_VER_MIN(2,6,25) 862 862 vbpci_printk(KERN_DEBUG, pPciDev, "ioremap() failed\n"); 863 863 #else … … 956 956 * @param pRegs Register set. Removed in 2.6.19. 957 957 */ 958 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,19) && !defined(DOXYGEN_RUNNING)958 #if RTLNX_VER_MIN(2,6,19) && !defined(DOXYGEN_RUNNING) 959 959 static irqreturn_t vboxPciOsIrqHandler(int iIrq, void *pvDevId) 960 960 #else … … 992 992 #ifdef VBOX_WITH_SHARED_PCI_INTERRUPTS 993 993 /* Allow interrupts sharing. */ 994 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,20)994 # if RTLNX_VER_MIN(2,6,20) 995 995 IRQF_SHARED, 996 996 # else … … 1002 1002 /* We don't allow interrupts sharing */ 1003 1003 /* 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) 1005 1005 IRQF_DISABLED, /* keep irqs disabled when calling the action handler */ 1006 1006 # else -
trunk/src/VBox/HostDrivers/VBoxPci/linux/files_vboxpci
r82968 r85698 64 64 ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \ 65 65 ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \ 66 ${PATH_ROOT}/include/iprt/linux/version.h=>include/iprt/linux/version.h \ 66 67 ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \ 67 68 ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \ -
trunk/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
r85505 r85698 39 39 40 40 #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) 42 42 /** 43 43 * Starting with 2.6.23 we can use __get_vm_area and map_vm_area to allocate … … 197 197 * in the free function, if nothing else... 198 198 */ 199 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17,0)199 # if RTLNX_VER_MAX(3,17,0) 200 200 struct page **papPagesIterator = papPages; 201 201 # endif … … 203 203 pVmArea->pages = papPages; 204 204 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) 206 206 &papPagesIterator 207 207 # else … … 216 216 } 217 217 /* bail out */ 218 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17,0)218 # if RTLNX_VER_MAX(3,17,0) 219 219 pVmArea->nr_pages = papPagesIterator - papPages; 220 220 # endif -
trunk/src/VBox/Runtime/r0drv/linux/initterm-r0drv-linux.c
r82968 r85698 40 40 *********************************************************************************************************************************/ 41 41 /** The IPRT work queue. */ 42 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,41)42 #if RTLNX_VER_MIN(2,5,41) 43 43 static struct workqueue_struct *g_prtR0LnxWorkQueue; 44 44 #else … … 58 58 IPRT_LINUX_SAVE_EFL_AC(); 59 59 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) 62 62 INIT_WORK(pWork, pfnWorker); 63 63 # else … … 84 84 IPRT_LINUX_SAVE_EFL_AC(); 85 85 86 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,41)86 #if RTLNX_VER_MIN(2,5,41) 87 87 flush_workqueue(g_prtR0LnxWorkQueue); 88 88 #else … … 99 99 IPRT_LINUX_SAVE_EFL_AC(); 100 100 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) 103 103 g_prtR0LnxWorkQueue = create_workqueue("iprt-VBoxWQueue"); 104 104 #else … … 119 119 120 120 rtR0LnxWorkqueueFlush(); 121 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,41)121 #if RTLNX_VER_MIN(2,5,41) 122 122 destroy_workqueue(g_prtR0LnxWorkQueue); 123 123 g_prtR0LnxWorkQueue = NULL; -
trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
r85516 r85698 57 57 * This is a must for 5.8+, but we enable it all the way back to 3.2.x for 58 58 * 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) 60 60 # define IPRT_USE_ALLOC_VM_AREA_FOR_EXEC 61 61 #endif … … 66 66 * It should be safe to use vm_insert_page() older kernels as well. 67 67 */ 68 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,23)68 #if RTLNX_VER_MIN(2,6,23) 69 69 # define VBOX_USE_INSERT_PAGE 70 70 #endif 71 71 #if defined(CONFIG_X86_PAE) \ 72 72 && ( 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) ) 75 74 # define VBOX_USE_PAE_HACK 76 75 #endif 77 76 78 77 /* 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) 80 79 # define gfp_t unsigned 81 80 #endif … … 84 83 * Wrappers around mmap_lock/mmap_sem difference. 85 84 */ 86 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8,0)85 #if RTLNX_VER_MIN(5,8,0) 87 86 # define LNX_MM_DOWN_READ(a_pMm) down_read(&(a_pMm)->mmap_lock) 88 87 # define LNX_MM_UP_READ(a_pMm) up_read(&(a_pMm)->mmap_lock) … … 252 251 if (R3PtrFixed != (RTR3PTR)-1) 253 252 { 254 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5,0)253 #if RTLNX_VER_MIN(3,5,0) 255 254 ulAddr = vm_mmap(NULL, R3PtrFixed, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, 0); 256 255 #else … … 262 261 else 263 262 { 264 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5,0)263 #if RTLNX_VER_MIN(3,5,0) 265 264 ulAddr = vm_mmap(NULL, 0, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS, 0); 266 265 #else … … 298 297 static void rtR0MemObjLinuxDoMunmap(void *pv, size_t cb, struct task_struct *pTask) 299 298 { 300 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5,0)299 #if RTLNX_VER_MIN(3,5,0) 301 300 Assert(pTask == current); RT_NOREF_PV(pTask); 302 301 vm_munmap((unsigned long)pv, cb); … … 359 358 * For small allocations we'll try contiguous first and then fall back on page by page. 360 359 */ 361 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,22)360 #if RTLNX_VER_MIN(2,4,22) 362 361 if ( fContiguous 363 362 || cb <= PAGE_SIZE * 2) … … 418 417 pMemLnx->fExecutable = fExecutable; 419 418 420 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5,0)419 #if RTLNX_VER_MAX(4,5,0) 421 420 /* 422 421 * Reserve the pages. … … 475 474 while (iPage-- > 0) 476 475 { 477 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5,0)476 #if RTLNX_VER_MAX(4,5,0) 478 477 /* See SetPageReserved() in rtR0MemObjLinuxAllocPages() */ 479 478 ClearPageReserved(pMemLnx->apPages[iPage]); 480 479 #endif 481 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4,22)480 #if RTLNX_VER_MAX(2,4,22) 482 481 if (pMemLnx->fExecutable) 483 482 MY_SET_PAGES_NOEXEC(pMemLnx->apPages[iPage], 1); … … 488 487 * Free the pages. 489 488 */ 490 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,22)489 #if RTLNX_VER_MIN(2,4,22) 491 490 if (!pMemLnx->fContiguous) 492 491 { … … 545 544 * Use vmap - 2.4.22 and later. 546 545 */ 547 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,22)546 #if RTLNX_VER_MIN(2,4,22) 548 547 pgprot_t fPg; 549 548 pgprot_val(fPg) = _PAGE_PRESENT | _PAGE_RW; … … 620 619 static void rtR0MemObjLinuxVUnmap(PRTR0MEMOBJLNX pMemLnx) 621 620 { 622 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,22)621 #if RTLNX_VER_MIN(2,4,22) 623 622 # ifdef IPRT_USE_ALLOC_VM_AREA_FOR_EXEC 624 623 if (pMemLnx->pArea) … … 683 682 if (!PageReserved(pMemLnx->apPages[iPage])) 684 683 SetPageDirty(pMemLnx->apPages[iPage]); 685 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6,0)684 #if RTLNX_VER_MIN(4,6,0) 686 685 put_page(pMemLnx->apPages[iPage]); 687 686 #else … … 746 745 int rc; 747 746 748 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,22)747 #if RTLNX_VER_MIN(2,4,22) 749 748 rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, PAGE_SIZE, GFP_HIGHUSER, 750 749 false /* non-contiguous */, fExecutable, VERR_NO_MEMORY); … … 995 994 { 996 995 pgd_t Global; 997 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12,0)996 #if RTLNX_VER_MIN(4,12,0) 998 997 p4d_t Four; 999 998 #endif 1000 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,11)999 #if RTLNX_VER_MIN(2,6,11) 1001 1000 pud_t Upper; 1002 1001 #endif … … 1013 1012 if (RT_UNLIKELY(pgd_none(u.Global))) 1014 1013 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) 1017 1016 u.Four = *p4d_offset(&u.Global, ulAddr); 1018 1017 if (RT_UNLIKELY(p4d_none(u.Four))) … … 1033 1032 if (RT_UNLIKELY(pud_none(u.Upper))) 1034 1033 return NULL; 1035 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,25)1034 # if RTLNX_VER_MIN(2,6,25) 1036 1035 if (pud_large(u.Upper)) 1037 1036 { … … 1049 1048 if (RT_UNLIKELY(pmd_none(u.Middle))) 1050 1049 return NULL; 1051 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,0)1050 #if RTLNX_VER_MIN(2,6,0) 1052 1051 if (pmd_large(u.Middle)) 1053 1052 { … … 1060 1059 #endif 1061 1060 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. */ 1063 1062 pEntry = pte_offset_map(&u.Middle, ulAddr); 1064 1063 #else … … 1068 1067 return NULL; 1069 1068 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) 1071 1070 pte_unmap(pEntry); 1072 1071 #endif … … 1120 1119 1121 1120 /* 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) 1125 1122 # define GET_USER_PAGES_API KERNEL_VERSION(4, 10, 0) /* no typo! */ 1126 1123 #else … … 1134 1131 struct task_struct *pTask = rtR0ProcessToLinuxTask(R0Process); 1135 1132 struct vm_area_struct **papVMAs; 1136 PRTR0MEMOBJLNX pMemLnx;1133 PRTR0MEMOBJLNX pMemLnx; 1137 1134 int rc = VERR_NO_MEMORY; 1138 1135 int const fWrite = fAccess & RTMEM_PROT_WRITE ? 1 : 0; … … 1209 1206 cPages, /* How many pages. */ 1210 1207 /* 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) 1213 1209 fWrite ? FOLL_WRITE | /* Write to memory. */ 1214 1210 FOLL_FORCE /* force write access. */ … … 1265 1261 if (!PageReserved(pMemLnx->apPages[rc])) 1266 1262 SetPageDirty(pMemLnx->apPages[rc]); 1267 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6,0)1263 #if RTLNX_VER_MIN(4,6,0) 1268 1264 put_page(pMemLnx->apPages[rc]); 1269 1265 #else … … 1375 1371 DECLHIDDEN(int) rtR0MemObjNativeReserveKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment) 1376 1372 { 1377 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,22)1373 #if RTLNX_VER_MIN(2,4,22) 1378 1374 IPRT_LINUX_SAVE_EFL_AC(); 1379 1375 const size_t cPages = cb >> PAGE_SHIFT; … … 1500 1496 if (pMemLnxToMap->cPages) 1501 1497 { 1502 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,22)1498 #if RTLNX_VER_MIN(2,4,22) 1503 1499 /* 1504 1500 * Use vmap - 2.4.22 and later. … … 1545 1541 */ 1546 1542 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) 1548 1544 /* 1549 1545 * ioremap() defaults to no caching since the 2.6 kernels. … … 1695 1691 for (iPage = offSub >> PAGE_SHIFT; iPage < cPages; iPage++, ulAddrCur += PAGE_SIZE) 1696 1692 { 1697 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,11)1693 #if RTLNX_VER_MAX(2,6,11) 1698 1694 RTHCPHYS Phys = page_to_phys(pMemLnxToMap->apPages[iPage]); 1699 1695 #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) 1701 1697 struct vm_area_struct *vma = find_vma(pTask->mm, ulAddrCur); /* this is probably the same for all the pages... */ 1702 1698 AssertBreakStmt(vma, rc = VERR_INTERNAL_ERROR); 1703 1699 #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) 1705 1701 /* remap_page_range() limitation on x86 */ 1706 1702 AssertBreakStmt(Phys < _4G, rc = VERR_NO_MEMORY); 1707 1703 #endif 1708 1704 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) 1710 1706 rc = vm_insert_page(vma, ulAddrCur, pMemLnxToMap->apPages[iPage]); 1711 1707 /* Thes flags help making 100% sure some bad stuff wont happen (swap, core, ++). 1712 1708 * 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) 1714 1710 vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; 1715 1711 #else 1716 1712 vma->vm_flags |= VM_RESERVED; 1717 1713 #endif 1718 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,11)1714 #elif RTLNX_VER_MIN(2,6,11) 1719 1715 rc = remap_pfn_range(vma, ulAddrCur, page_to_pfn(pMemLnxToMap->apPages[iPage]), PAGE_SIZE, fPg); 1720 1716 #elif defined(VBOX_USE_PAE_HACK) … … 1722 1718 if (!rc) 1723 1719 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) 1725 1721 rc = remap_page_range(vma, ulAddrCur, Phys, PAGE_SIZE, fPg); 1726 1722 #else /* 2.4 */ … … 1750 1746 for (iPage = offSub >> PAGE_SHIFT; iPage < cPages; iPage++, ulAddrCur += PAGE_SIZE, Phys += PAGE_SIZE) 1751 1747 { 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) 1753 1749 struct vm_area_struct *vma = find_vma(pTask->mm, ulAddrCur); /* this is probably the same for all the pages... */ 1754 1750 AssertBreakStmt(vma, rc = VERR_INTERNAL_ERROR); 1755 1751 #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) 1757 1753 /* remap_page_range() limitation on x86 */ 1758 1754 AssertBreakStmt(Phys < _4G, rc = VERR_NO_MEMORY); 1759 1755 #endif 1760 1756 1761 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,11)1757 #if RTLNX_VER_MIN(2,6,11) 1762 1758 rc = remap_pfn_range(vma, ulAddrCur, Phys, PAGE_SIZE, fPg); 1763 1759 #elif defined(VBOX_USE_PAE_HACK) … … 1765 1761 if (!rc) 1766 1762 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) 1768 1764 rc = remap_page_range(vma, ulAddrCur, Phys, PAGE_SIZE, fPg); 1769 1765 #else /* 2.4 */ … … 1780 1776 1781 1777 #ifdef CONFIG_NUMA_BALANCING 1782 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13,0)1778 # if RTLNX_VER_MAX(3,13,0) 1783 1779 # ifdef RHEL_RELEASE_CODE 1784 1780 # if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(7, 0) -
trunk/src/VBox/Runtime/r0drv/linux/memuserkernel-r0drv-linux.c
r82968 r85698 67 67 { 68 68 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) 70 70 bool fRc = access_ok((void *)R3Ptr, 1); 71 71 #else … … 87 87 #else 88 88 # 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) 90 90 return !access_ok(pv, 1); 91 91 #else 92 92 return !access_ok(VERIFY_READ, pv, 1); 93 #endif /* LINUX_VERSION_CODE */93 #endif 94 94 #endif 95 95 } … … 113 113 static int rtR0MemKernelCopyLnxWorker(void *pvDst, void const *pvSrc, size_t cb) 114 114 { 115 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,55)115 #if RTLNX_VER_MIN(2,5,55) 116 116 /* _ASM_EXTABLE was introduced in 2.6.25 from what I can tell. Using #ifndef 117 117 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 43 43 * Defined Constants And Macros * 44 44 *********************************************************************************************************************************/ 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) 46 46 # define VBOX_NR_CPUMASK_BITS (nr_cpumask_bits) /* same as nr_cpu_ids */ 47 47 #else … … 95 95 { 96 96 #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) 98 98 return idCpu < VBOX_NR_CPUMASK_BITS && cpu_possible(idCpu); 99 99 # else /* < 2.5.29 */ … … 126 126 { 127 127 #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) 129 129 return num_possible_cpus(); 130 # elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 5,0)130 # elif RTLNX_VER_MAX(2,5,0) 131 131 return smp_num_cpus; 132 132 # else … … 145 145 { 146 146 #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) 148 148 return idCpu < VBOX_NR_CPUMASK_BITS && cpu_online(idCpu); 149 149 # else /* 2.4: */ … … 181 181 { 182 182 #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) 184 184 return num_online_cpus(); 185 185 # else … … 217 217 #ifdef CONFIG_SMP 218 218 219 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27)219 # if RTLNX_VER_MIN(2,6,27) 220 220 /** 221 221 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER, does hit … … 281 281 { 282 282 /* 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) 284 284 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) 286 286 int rc = smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* wait */); 287 287 Assert(!rc); NOREF(rc); … … 337 337 338 338 RTThreadPreemptDisable(&PreemptState); 339 # if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3,0)339 # if RTLNX_VER_MIN(5,3,0) 340 340 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) 342 342 int rc = smp_call_function(rtmpLinuxWrapper, &Args, 1 /* wait */); 343 343 Assert(rc == 0); NOREF(rc); … … 357 357 358 358 359 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,27) && defined(CONFIG_SMP)359 #if RTLNX_VER_MAX(2,6,27) && defined(CONFIG_SMP) 360 360 /** 361 361 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER … … 385 385 int rc; 386 386 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 */ 388 388 cpumask_var_t DstCpuMask; 389 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27)389 # elif RTLNX_VER_MIN(2,6,27) 390 390 cpumask_t DstCpuMask; 391 391 # endif … … 397 397 * Prepare the CPU mask before we disable preemption. 398 398 */ 399 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,30)399 # if RTLNX_VER_MIN(2,6,30) 400 400 if (!zalloc_cpumask_var(&DstCpuMask, GFP_KERNEL)) 401 401 return VERR_NO_MEMORY; 402 402 cpumask_set_cpu(idCpu1, DstCpuMask); 403 403 cpumask_set_cpu(idCpu2, DstCpuMask); 404 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,28)404 # elif RTLNX_VER_MIN(2,6,28) 405 405 if (!alloc_cpumask_var(&DstCpuMask, GFP_KERNEL)) 406 406 return VERR_NO_MEMORY; … … 408 408 cpumask_set_cpu(idCpu1, DstCpuMask); 409 409 cpumask_set_cpu(idCpu2, DstCpuMask); 410 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27)410 # elif RTLNX_VER_MIN(2,6,27) 411 411 cpus_clear(DstCpuMask); 412 412 cpu_set(idCpu1, DstCpuMask); … … 437 437 Args.cHits = 0; 438 438 439 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,28)439 # if RTLNX_VER_MIN(2,6,28) 440 440 smp_call_function_many(DstCpuMask, rtmpLinuxWrapperPostInc, &Args, !fCallSelf /* wait */); 441 441 rc = 0; 442 # elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27)442 # elif RTLNX_VER_MIN(2,6,27) 443 443 rc = smp_call_function_mask(DstCpuMask, rtmpLinuxWrapperPostInc, &Args, !fCallSelf /* wait */); 444 444 # else /* older kernels */ … … 481 481 482 482 RTThreadPreemptRestore(&PreemptState);; 483 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,28)483 # if RTLNX_VER_MIN(2,6,28) 484 484 free_cpumask_var(DstCpuMask); 485 485 # endif … … 502 502 503 503 504 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,19) && defined(CONFIG_SMP)504 #if RTLNX_VER_MAX(2,6,19) && defined(CONFIG_SMP) 505 505 /** 506 506 * Wrapper between the native linux per-cpu callbacks and PFNRTWORKER … … 545 545 if (RTMpIsCpuOnline(idCpu)) 546 546 { 547 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27)547 # if RTLNX_VER_MIN(2,6,27) 548 548 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) 550 550 rc = smp_call_function_single(idCpu, rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */); 551 551 # else /* older kernels */ … … 573 573 574 574 575 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,19) && defined(CONFIG_SMP)575 #if RTLNX_VER_MIN(2,6,19) && defined(CONFIG_SMP) 576 576 /** 577 577 * Dummy callback used by RTMpPokeCpu. … … 588 588 RTDECL(int) RTMpPokeCpu(RTCPUID idCpu) 589 589 { 590 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,19)590 #if RTLNX_VER_MIN(2,6,19) 591 591 IPRT_LINUX_SAVE_EFL_AC(); 592 592 int rc; … … 596 596 { 597 597 # ifdef CONFIG_SMP 598 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27)598 # if RTLNX_VER_MIN(2,6,27) 599 599 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) 601 601 rc = smp_call_function_single(idCpu, rtmpLinuxPokeCpuCallback, NULL, 0 /* retry */, 0 /* wait */); 602 602 # else /* older kernels */ -
trunk/src/VBox/Runtime/r0drv/linux/mpnotification-r0drv-linux.c
r82968 r85698 38 38 #include "r0drv/mp-r0drv.h" 39 39 40 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10,0)40 #if RTLNX_VER_MIN(4,10,0) 41 41 42 42 static enum cpuhp_state g_rtR0MpOnline; … … 86 86 } 87 87 88 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,71) && defined(CONFIG_SMP)88 #elif RTLNX_VER_MIN(2,5,71) && defined(CONFIG_SMP) 89 89 90 90 static int rtMpNotificationLinuxCallback(struct notifier_block *pNotifierBlock, unsigned long ulNativeEvent, void *pvCpu); -
trunk/src/VBox/Runtime/r0drv/linux/rtStrFormatKernelAddress-r0drv-linux.c
r82968 r85698 42 42 signed int cchPrecision, unsigned int fFlags) 43 43 { 44 #if !defined(DEBUG) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,38)44 #if !defined(DEBUG) && RTLNX_VER_MIN(2,6,38) 45 45 RT_NOREF(cchWidth, cchPrecision); 46 46 /* use the Linux kernel function which is able to handle "%pK" */ -
trunk/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h
r85690 r85698 49 49 50 50 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) 71 53 # include <generated/autoconf.h> 72 54 #else … … 77 59 78 60 /* 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) 80 62 # error Sorry, we do not support 2.3 and earlier kernels. 81 63 #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) 83 65 # error Sorry, we do not support 2.5 series kernels (might work though). 84 66 #endif … … 86 68 #if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS) 87 69 # define MODVERSIONS 88 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5,71)70 # if RTLNX_VER_MAX(2,5,71) 89 71 # include <linux/modversions.h> 90 72 # endif 91 73 #endif 92 74 #ifndef KBUILD_STR 93 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,16)75 # if RTLNX_VER_MAX(2,6,16) 94 76 # define KBUILD_STR(s) s 95 77 # else … … 97 79 # endif 98 80 #endif 99 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3,0)81 # if RTLNX_VER_MIN(3,3,0) 100 82 # include <linux/kconfig.h> /* for macro IS_ENABLED */ 101 83 # endif … … 103 85 #include <linux/spinlock.h> 104 86 #include <linux/slab.h> 105 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,27)87 #if RTLNX_VER_MIN(2,6,27) 106 88 # include <linux/semaphore.h> 107 89 #else /* older kernels */ … … 109 91 #endif /* older kernels */ 110 92 #include <linux/module.h> 111 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,0)93 #if RTLNX_VER_MIN(2,6,0) 112 94 # include <linux/moduleparam.h> 113 95 #endif … … 115 97 #include <linux/init.h> 116 98 #include <linux/fs.h> 117 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,0)99 #if RTLNX_VER_MIN(2,6,0) 118 100 # include <linux/namei.h> 119 101 #endif … … 124 106 #include <linux/sched.h> 125 107 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) 132 113 # include <linux/sched/rt.h> 133 114 #endif 134 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11,0)115 #if RTLNX_VER_MIN(4,11,0) 135 116 # include <linux/sched/signal.h> 136 117 # include <linux/sched/types.h> 137 118 #endif 138 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,7)119 #if RTLNX_VER_MIN(2,6,7) 139 120 # include <linux/jiffies.h> 140 121 #endif 141 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,16)122 #if RTLNX_VER_MIN(2,6,16) 142 123 # include <linux/ktime.h> 143 124 # include <linux/hrtimer.h> 144 125 #endif 145 126 #include <linux/wait.h> 146 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,71)127 #if RTLNX_VER_MIN(2,5,71) 147 128 # include <linux/cpu.h> 148 129 # include <linux/notifier.h> 149 130 #endif 150 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1,0)131 #if RTLNX_VER_MIN(5,1,0) 151 132 # include <uapi/linux/mman.h> 152 133 #endif … … 171 152 172 153 /* 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) 174 155 # include <linux/preempt.h> 175 156 #endif 176 157 177 158 /* for workqueue / task queues. */ 178 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,41)159 #if RTLNX_VER_MIN(2,5,41) 179 160 # include <linux/workqueue.h> 180 161 #else … … 182 163 #endif 183 164 184 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,4)165 #if RTLNX_VER_MIN(2,6,4) 185 166 # include <linux/kthread.h> 186 167 #endif 187 168 188 169 /* for cr4_init_shadow() / cpu_tlbstate. */ 189 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20,0)170 #if RTLNX_VER_MIN(3,20,0) 190 171 # include <asm/tlbflush.h> 191 172 #endif 192 173 193 174 /* for set_pages_x() */ 194 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12,0)175 #if RTLNX_VER_MIN(4,12,0) 195 176 # include <asm/set_memory.h> 196 177 #endif 197 178 198 179 /* 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)) 200 181 # include <asm/tlbflush.h> 201 182 #endif 202 183 203 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7,0)184 #if RTLNX_VER_MIN(3,7,0) 204 185 # include <asm/smap.h> 205 186 #else … … 208 189 #endif 209 190 210 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,0)191 #if RTLNX_VER_MAX(2,6,0) 211 192 # ifndef page_to_pfn 212 193 # define page_to_pfn(page) ((page) - mem_map) … … 225 206 * 2.4 / early 2.6 compatibility wrappers 226 207 */ 227 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,7)208 #if RTLNX_VER_MAX(2,6,7) 228 209 229 210 # ifndef MAX_JIFFY_OFFSET … … 231 212 # endif 232 213 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) 234 215 235 216 DECLINLINE(unsigned int) jiffies_to_msecs(unsigned long cJiffies) … … 266 247 * 2.4 compatibility wrappers 267 248 */ 268 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,0)249 #if RTLNX_VER_MAX(2,6,0) 269 250 270 251 # define prepare_to_wait(q, wait, state) \ … … 300 281 * This sucks soooo badly on x86! Why don't they export __PAGE_KERNEL_EXEC so PAGE_KERNEL_EXEC would be usable? 301 282 */ 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) 303 284 # 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) 305 286 # ifdef __PAGE_KERNEL_EXEC 306 287 /* >= 2.6.27 */ … … 320 301 #ifndef NO_REDHAT_HACKS 321 302 /* accounting. */ 322 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,0)303 # if RTLNX_VER_MAX(2,6,0) 323 304 # ifdef VM_ACCOUNT 324 305 # define USE_RHEL4_MUNMAP … … 327 308 328 309 /* backported remap_page_range. */ 329 # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,0)310 # if RTLNX_VER_MAX(2,6,0) 330 311 # include <asm/tlb.h> 331 312 # ifdef tlb_vma /* probably not good enough... */ … … 361 342 #endif 362 343 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. */ 365 346 # define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages) 366 347 # define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages) … … 473 454 * Whether the kernel support high resolution timers (Linux kernel versions 474 455 * 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) 476 457 # define IPRT_LINUX_HAS_HRTIMER 477 458 #endif … … 480 461 * Workqueue stuff, see initterm-r0drv-linux.c. 481 462 */ 482 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,41)463 #if RTLNX_VER_MIN(2,5,41) 483 464 typedef struct work_struct RTR0LNXWORKQUEUEITEM; 484 465 #else -
trunk/src/VBox/Runtime/r0drv/linux/thread-r0drv-linux.c
r82968 r85698 34 34 35 35 #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) 37 37 # include <iprt/asm-amd64-x86.h> 38 38 #endif … … 88 88 { 89 89 IPRT_LINUX_SAVE_EFL_AC(); 90 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,20)90 #if RTLNX_VER_MIN(2,4,20) 91 91 yield(); 92 92 #else … … 119 119 if (c != 0) 120 120 return false; 121 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,32)121 # if RTLNX_VER_MIN(2,5,32) 122 122 if (in_atomic()) 123 123 return false; 124 124 # endif 125 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,28)125 # if RTLNX_VER_MIN(2,5,28) 126 126 if (irqs_disabled()) 127 127 return false; … … 139 139 { 140 140 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) 142 142 return !!test_tsk_thread_flag(current, TIF_NEED_RESCHED); 143 143 144 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4,20)144 #elif RTLNX_VER_MIN(2,4,20) 145 145 return !!need_resched(); 146 146 147 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 1,110)147 #elif RTLNX_VER_MIN(2,1,110) 148 148 return current->need_resched != 0; 149 149 -
trunk/src/VBox/Runtime/r0drv/linux/thread2-r0drv-linux.c
r82968 r85698 37 37 #include "internal/thread.h" 38 38 39 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11,0)39 #if RTLNX_VER_MIN(4,11,0) 40 40 #include <uapi/linux/sched/types.h> 41 41 #endif /* >= KERNEL_VERSION(4, 11, 0) */ … … 55 55 DECLHIDDEN(int) rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType) 56 56 { 57 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,11)57 #if RTLNX_VER_MIN(2,6,11) 58 58 /* See comment near MAX_RT_PRIO in linux/sched.h for details on 59 59 sched_priority. */ … … 123 123 124 124 125 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,4)125 #if RTLNX_VER_MIN(2,6,4) 126 126 /** 127 127 * Native kernel thread wrapper function. … … 143 143 DECLHIDDEN(int) rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread) 144 144 { 145 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,4)145 #if RTLNX_VER_MIN(2,6,4) 146 146 struct task_struct *NativeThread; 147 147 IPRT_LINUX_SAVE_EFL_AC(); -
trunk/src/VBox/Runtime/r0drv/linux/threadctxhooks-r0drv-linux.c
r82968 r85698 47 47 * got it backported. 48 48 */ 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) 50 50 51 51 … … 73 73 /** The linux callbacks. */ 74 74 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) 76 76 /** Starting with 3.1.19, the linux kernel doesn't restore kernel RFLAGS during 77 77 * task switch, so we have to do that ourselves. (x86 code is not affected.) */ … … 110 110 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) 111 111 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) 113 113 pThis->fSavedRFlags = fSavedEFlags; 114 114 # endif … … 143 143 144 144 #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) 146 146 fSavedEFlags &= ~RT_BIT_64(18) /*X86_EFL_AC*/; 147 147 fSavedEFlags |= pThis->fSavedRFlags & RT_BIT_64(18) /*X86_EFL_AC*/; … … 199 199 pThis->PreemptOps.sched_in = rtThreadCtxHooksLnxSchedIn; 200 200 201 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2,0)201 #if RTLNX_VER_MIN(4,2,0) 202 202 preempt_notifier_inc(); 203 203 #endif … … 236 236 } 237 237 238 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2,0)238 #if RTLNX_VER_MIN(4,2,0) 239 239 preempt_notifier_dec(); 240 240 #endif -
trunk/src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c
r85208 r85698 33 33 #include "internal/iprt.h" 34 34 /* 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) 36 36 # define RTTIME_INCL_TIMEVAL 37 #elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 17,0)37 #elif RTLNX_VER_MAX(3,17,0) 38 38 # define RTTIME_INCL_TIMESPEC 39 39 #endif … … 45 45 DECLINLINE(uint64_t) rtTimeGetSystemNanoTS(void) 46 46 { 47 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6,0)47 #if RTLNX_VER_MIN(5,6,0) 48 48 /* 49 49 * Starting with kernel version 5.6-rc3 only 64-bit time interfaces … … 57 57 return u64; 58 58 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! */ 60 60 /* 61 61 * Use ktime_get_ts, this is also what clock_gettime(CLOCK_MONOTONIC,) is using. … … 67 67 return u64; 68 68 69 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,60)69 #elif RTLNX_VER_MIN(2,5,60) 70 70 /* 71 71 * Seems there is no way of getting to the exact source of … … 189 189 { 190 190 IPRT_LINUX_SAVE_EFL_AC(); 191 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17,0)191 #if RTLNX_VER_MIN(3,17,0) 192 192 struct timespec64 Ts; 193 193 ktime_get_real_ts64(&Ts); /* ktime_get_real_ts64 was added as a macro in 3.17, function since 4.18. */ … … 195 195 return RTTimeSpecSetTimespec64(pTime, &Ts); 196 196 197 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6,16)197 #elif RTLNX_VER_MIN(2,6,16) 198 198 struct timespec Ts; 199 199 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 51 51 #endif 52 52 53 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6,31)53 #if RTLNX_VER_MAX(2,6,31) 54 54 # define mod_timer_pinned mod_timer 55 55 # define HRTIMER_MODE_ABS_PINNED HRTIMER_MODE_ABS … … 368 368 if (fPinned) 369 369 { 370 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8,0)370 # if RTLNX_VER_MIN(4,8,0) 371 371 mod_timer(&pSubTimer->u.Std.LnxTimer, pSubTimer->u.Std.ulNextJiffies); 372 372 # else … … 721 721 722 722 723 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15,0)723 #if RTLNX_VER_MIN(4,15,0) 724 724 /** 725 725 * Timer callback function for standard timers. … … 840 840 if (pTimer->fSpecificCpu || pTimer->fAllCpus) 841 841 { 842 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8,0)842 # if RTLNX_VER_MIN(4,8,0) 843 843 mod_timer(&pSubTimer->u.Std.LnxTimer, ulNextJiffies); 844 844 # else … … 903 903 if (pTimer->fSpecificCpu || pTimer->fAllCpus) 904 904 { 905 # if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8,0)905 # if RTLNX_VER_MIN(4,8,0) 906 906 mod_timer(&pSubTimer->u.Std.LnxTimer, pSubTimer->u.Std.ulNextJiffies); 907 907 # else … … 1520 1520 /* For paranoid reasons, defer actually destroying the semaphore when 1521 1521 in atomic or interrupt context. */ 1522 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,32)1522 #if RTLNX_VER_MIN(2,5,32) 1523 1523 if (in_atomic() || in_interrupt()) 1524 1524 #else … … 1621 1621 #endif 1622 1622 { 1623 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15,0)1623 #if RTLNX_VER_MIN(4,15,0) 1624 1624 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) 1626 1626 init_timer_pinned(&pTimer->aSubTimers[iCpu].u.Std.LnxTimer); 1627 1627 #else 1628 1628 init_timer(&pTimer->aSubTimers[iCpu].u.Std.LnxTimer); 1629 1629 #endif 1630 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15,0)1630 #if RTLNX_VER_MAX(4,15,0) 1631 1631 pTimer->aSubTimers[iCpu].u.Std.LnxTimer.data = (unsigned long)&pTimer->aSubTimers[iCpu]; 1632 1632 pTimer->aSubTimers[iCpu].u.Std.LnxTimer.function = rtTimerLinuxStdCallback; … … 1687 1687 #endif 1688 1688 /* */ 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) 1690 1690 /* On 4.9, 4.10 and 4.12 we've observed tstRTR0Timer failures of the omni timer tests 1691 1691 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 184 184 * Initialize the wait queue related bits. 185 185 */ 186 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5,39)186 #if RTLNX_VER_MIN(2,5,39) 187 187 init_wait((&pWait->WaitQE)); 188 188 #else
Note:
See TracChangeset
for help on using the changeset viewer.