Index: include/VBox/VBoxGuest.h
===================================================================
--- include/VBox/VBoxGuest.h	(revision 37995)
+++ include/VBox/VBoxGuest.h	(working copy)
@@ -175,7 +175,7 @@
 # define VBOXGUEST_IOCTL_CODE_FAST_(Function)       _IO(  'V', (Function))
 # define VBOXGUEST_IOCTL_STRIP_SIZE(Code)           VBOXGUEST_IOCTL_CODE_(_IOC_NR((Code)), 0)
 
-#elif defined(RT_OS_FREEBSD) /** @todo r=bird: Please do it like SUPDRVIOC to keep it as similar as possible. */
+#elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__) /** @todo r=bird: Please do it like SUPDRVIOC to keep it as similar as possible. */
 # include <sys/ioccom.h>
 
 # define VBOXGUEST_IOCTL_CODE_(Function, Size)      _IOWR('V', (Function), VBGLBIGREQ)
Index: include/VBox/usb.h
===================================================================
--- include/VBox/usb.h	(revision 37995)
+++ include/VBox/usb.h	(working copy)
@@ -117,7 +117,7 @@
     uint8_t         bBus;
     /** The port number. */
     uint8_t         bPort;
-#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
+#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
     /** Device number. */
     uint8_t         bDevNum;
 #endif
Index: include/iprt/types.h
===================================================================
--- include/iprt/types.h	(revision 37995)
+++ include/iprt/types.h	(working copy)
@@ -53,7 +53,7 @@
 #  endif
 #  include <sys/types.h>
 
-# elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
+# elif (defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)) && defined(_KERNEL)
     /*
      * Kludge for the FreeBSD kernel:
      *  stddef.h and sys/types.h have slightly different offsetof definitions
@@ -71,7 +71,7 @@
 #   error "offsetof is not defined..."
 #  endif
 
-# elif defined(RT_OS_FREEBSD) && HC_ARCH_BITS == 64 && defined(RT_ARCH_X86)
+# elif (defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)) && HC_ARCH_BITS == 64 && defined(RT_ARCH_X86)
     /*
      * Kludge for compiling 32-bit code on a 64-bit FreeBSD:
      *  FreeBSD declares uint64_t and int64_t wrong (long unsigned and long int
Index: include/iprt/stdint.h
===================================================================
--- include/iprt/stdint.h	(revision 37995)
+++ include/iprt/stdint.h	(working copy)
@@ -34,6 +34,7 @@
  */
 #if !(defined(RT_OS_LINUX) && defined(__KERNEL__))  \
   && !(defined(RT_OS_FREEBSD) && defined(_KERNEL)) \
+  && !(defined(__FreeBSD_kernel__) && defined(_KERNEL)) \
   && !defined(_MSC_VER) \
   && !defined(__IBMC__) \
   && !defined(__IBMCPP__) \
@@ -62,7 +63,7 @@
 #  define UINT32_C(Value)   (Value ## U)
 # endif /* 64-bit darwin kludge. */
 
-#elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
+#elif (defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)) && defined(_KERNEL)
 
 # ifndef __STDC_CONSTANT_MACROS
 #  define __STDC_CONSTANT_MACROS
Index: include/iprt/string.h
===================================================================
--- include/iprt/string.h	(revision 37995)
+++ include/iprt/string.h	(working copy)
@@ -41,7 +41,7 @@
 # include "xf86_ansic.h"
 RT_C_DECLS_END
 
-#elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
+#elif (defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)) && defined(_KERNEL)
 RT_C_DECLS_BEGIN
 /** @todo
  * XXX: Very ugly hack to get things build on recent FreeBSD builds. They have
@@ -98,7 +98,7 @@
 RT_C_DECLS_END
 #endif
 
-#if defined(RT_OS_FREEBSD) && defined(_KERNEL)
+#if (defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)) && defined(_KERNEL)
 RT_C_DECLS_BEGIN
 #if __FreeBSD_version < 900000
 void *memchr(const void *pv, int ch, size_t cb);
Index: include/iprt/spinlock.h
===================================================================
--- include/iprt/spinlock.h	(revision 37995)
+++ include/iprt/spinlock.h	(working copy)
@@ -61,7 +61,7 @@
     unsigned long   flFlags;
 #  define RTSPINLOCKTMP_INITIALIZER { 0 }
 
-# elif defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_SOLARIS)
+# elif defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__) || defined(RT_OS_SOLARIS)
     /** The saved [R|E]FLAGS. */
     RTCCUINTREG     uFlags;
 #  define RTSPINLOCKTMP_INITIALIZER { 0 }
Index: include/iprt/stdarg.h
===================================================================
--- include/iprt/stdarg.h	(revision 37995)
+++ include/iprt/stdarg.h	(working copy)
@@ -27,10 +27,10 @@
 #define ___iprt_stdarg_h
 
 #if    !defined(IPRT_NO_CRT) \
-    && !(defined(RT_OS_FREEBSD) && defined(_KERNEL))
+    && !((defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)) && defined(_KERNEL))
 
 # include <stdarg.h>
-#elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
+#elif (defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)) && defined(_KERNEL)
 # include <machine/stdarg.h>
 #else
 # include <iprt/types.h>
Index: src/VBox/Devices/Storage/DrvHostBase.cpp
===================================================================
--- src/VBox/Devices/Storage/DrvHostBase.cpp	(revision 37995)
+++ src/VBox/Devices/Storage/DrvHostBase.cpp	(working copy)
@@ -96,7 +96,7 @@
         /*IN*/ ULONG                Length,
         /*IN*/ FS_INFORMATION_CLASS FileSystemInformationClass );
 
-#elif defined(RT_OS_FREEBSD)
+#elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 # include <sys/cdefs.h>
 # include <sys/param.h>
 # include <errno.h>
@@ -146,14 +146,14 @@
     if (    pThis->fMediaPresent
         &&  pThis->ppScsiTaskDI
         &&  pThis->cbBlock)
-#elif RT_OS_FREEBSD
+#elif RT_OS_FREEBSD || defined(__FreeBSD_kernel__)
     if (    pThis->fMediaPresent
         &&  pThis->cbBlock)
 #else
     if (pThis->fMediaPresent)
 #endif
     {
-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
+#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
         /*
          * Issue a READ(12) request.
          */
@@ -225,7 +225,7 @@
     {
         if (pThis->fMediaPresent)
         {
-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
+#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
             /** @todo write support... */
             rc = VERR_WRITE_PROTECT;
 
@@ -263,7 +263,7 @@
 
     if (pThis->fMediaPresent)
     {
-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
+#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
         rc = VINF_SUCCESS;
         /** @todo scsi device buffer flush... */
 #else
@@ -956,7 +956,7 @@
     IOObjectRelease(DVDServices);
     return rc;
 
-#elif defined(RT_OS_FREEBSD)
+#elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
     RTFILE hFileDevice;
     int rc = RTFileOpen(&hFileDevice, pThis->pszDeviceOpen, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     if (RT_FAILURE(rc))
@@ -1141,7 +1141,7 @@
  */
 static int drvHostBaseGetMediaSize(PDRVHOSTBASE pThis, uint64_t *pcb)
 {
-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
+#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
     /*
      * Try a READ_CAPACITY command...
      */
@@ -1219,7 +1219,7 @@
 }
 
 
-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
+#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 /**
  * Execute a SCSI command.
  *
@@ -1330,7 +1330,7 @@
 
     (*ppScsiTaskI)->Release(ppScsiTaskI);
 
-# elif defined(RT_OS_FREEBSD)
+# elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
     int rc = VINF_SUCCESS;
     int rcBSD = 0;
     union ccb DeviceCCB;
Index: src/VBox/Devices/Storage/DrvHostDVD.cpp
===================================================================
--- src/VBox/Devices/Storage/DrvHostDVD.cpp	(revision 37995)
+++ src/VBox/Devices/Storage/DrvHostDVD.cpp	(working copy)
@@ -89,7 +89,7 @@
 # undef _interlockedbittestandreset64
 # undef USE_MEDIA_POLLING
 
-#elif defined(RT_OS_FREEBSD)
+#elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 # include <sys/cdefs.h>
 # include <sys/param.h>
 # include <stdio.h>
@@ -146,7 +146,7 @@
             /*
              * Eject the disc.
              */
-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
+#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
             uint8_t abCmd[16] =
             {
                 SCSI_START_STOP_UNIT, 0, 0, 0, 2 /*eject+stop*/, 0,
@@ -236,7 +236,7 @@
  */
 static DECLCALLBACK(int) drvHostDvdDoLock(PDRVHOSTBASE pThis, bool fLock)
 {
-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
+#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
     uint8_t abCmd[16] =
     {
         SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL, 0, 0, 0, fLock, 0,
@@ -324,7 +324,7 @@
     /*
      * Poll for media change.
      */
-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
+#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 #ifdef RT_OS_DARWIN
     AssertReturn(pThis->ppScsiTaskDI, VERR_INTERNAL_ERROR);
 #endif
@@ -394,7 +394,7 @@
         /*
          * Poll for media change.
          */
-#if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
+#if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
         /* taken care of above. */
 #elif defined(RT_OS_LINUX)
         bool fMediaChanged = ioctl(RTFileToNative(pThis->hFileDevice), CDROM_MEDIA_CHANGED, CDSL_CURRENT) == 1;
@@ -424,7 +424,7 @@
     int rc;
     LogFlow(("%s: cmd[0]=%#04x txdir=%d pcbBuf=%d timeout=%d\n", __FUNCTION__, pbCmd[0], enmTxDir, *pcbBuf, cTimeoutMillies));
 
-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
+#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
     /*
      * Pass the request on to the internal scsi command interface.
      * The command seems to be 12 bytes long, the docs a bit copy&pasty on the command length point...
Index: src/VBox/Devices/Storage/DrvHostBase.h
===================================================================
--- src/VBox/Devices/Storage/DrvHostBase.h	(revision 37995)
+++ src/VBox/Devices/Storage/DrvHostBase.h	(working copy)
@@ -136,7 +136,7 @@
     uint8_t                *pbDoubleBuffer;
 #endif
 
-#ifdef RT_OS_FREEBSD
+#if defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
     /** The block size. Set when querying the media size. */
     uint32_t                cbBlock;
     /** SCSI bus number. */
@@ -185,7 +185,7 @@
 int DRVHostBaseMediaPresent(PDRVHOSTBASE pThis);
 void DRVHostBaseMediaNotPresent(PDRVHOSTBASE pThis);
 DECLCALLBACK(void) DRVHostBaseDestruct(PPDMDRVINS pDrvIns);
-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
+#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 DECLCALLBACK(int) DRVHostBaseScsiCmd(PDRVHOSTBASE pThis, const uint8_t *pbCmd, size_t cbCmd, PDMBLOCKTXDIR enmTxDir,
                                      void *pvBuf, uint32_t *pcbBuf, uint8_t *pbSense, size_t cbSense, uint32_t cTimeoutMillies);
 #endif
Index: src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp
===================================================================
--- src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp	(revision 37995)
+++ src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp	(working copy)
@@ -38,7 +38,7 @@
 # include <sys/errno.h>
 #elif defined(RT_OS_LINUX) && defined(__KERNEL__)
 # include <linux/errno.h>
-#elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
+#elif (defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)) && defined(_KERNEL)
 # include <sys/errno.h>
 #else
 # include <errno.h>
Index: src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp
===================================================================
--- src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp	(revision 37995)
+++ src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp	(working copy)
@@ -37,7 +37,7 @@
 # include <sys/errno.h>
 #elif defined(RT_OS_LINUX) && defined(__KERNEL__)
 # include <linux/errno.h>
-#elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
+#elif (defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)) && defined(_KERNEL)
 # include <sys/errno.h>
 #else
 # include <errno.h>
Index: src/VBox/Runtime/VBox/log-vbox.cpp
===================================================================
--- src/VBox/Runtime/VBox/log-vbox.cpp	(revision 37995)
+++ src/VBox/Runtime/VBox/log-vbox.cpp	(working copy)
@@ -131,7 +131,7 @@
 #  include <Windows.h>
 # elif defined(RT_OS_LINUX)
 #  include <unistd.h>
-# elif defined(RT_OS_FREEBSD)
+# elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 #  include <sys/param.h>
 #  include <sys/sysctl.h>
 #  include <sys/user.h>
@@ -368,7 +368,7 @@
             fclose(pFile);
         }
 
-#  elif defined(RT_OS_FREEBSD)
+#  elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
         /* Retrieve the required length first */
         int aiName[4];
         aiName[0] = CTL_KERN;
Index: src/VBox/Main/include/USBProxyService.h
===================================================================
--- src/VBox/Main/include/USBProxyService.h	(revision 37995)
+++ src/VBox/Main/include/USBProxyService.h	(working copy)
@@ -351,7 +351,7 @@
 };
 # endif /* RT_OS_WINDOWS */
 
-# ifdef RT_OS_FREEBSD
+# if defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 /**
  * The FreeBSD hosted USB Proxy Service.
  */
Index: src/VBox/Main/include/ConsoleImpl.h
===================================================================
--- src/VBox/Main/include/ConsoleImpl.h	(revision 37995)
+++ src/VBox/Main/include/ConsoleImpl.h	(working copy)
@@ -474,7 +474,7 @@
     HRESULT powerDown(IProgress *aProgress = NULL);
 
 /* Note: FreeBSD needs this whether netflt is used or not. */
-#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
+#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__))
     HRESULT attachToTapInterface(INetworkAdapter *networkAdapter);
     HRESULT detachFromTapInterface(INetworkAdapter *networkAdapter);
 #endif
@@ -763,7 +763,7 @@
     MediumAttachmentMap mapMediumAttachments;
 
 /* Note: FreeBSD needs this whether netflt is used or not. */
-#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
+#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__))
     Utf8Str      maTAPDeviceName[8];
     RTFILE       maTapFD[8];
 #endif
Index: src/VBox/Main/include/HostUSBDeviceImpl.h
===================================================================
--- src/VBox/Main/include/HostUSBDeviceImpl.h	(revision 37995)
+++ src/VBox/Main/include/HostUSBDeviceImpl.h	(working copy)
@@ -327,7 +327,7 @@
 
     friend class USBProxyServiceDarwin;
 #endif
-#ifdef RT_OS_FreeBSD
+#if defined(RT_OS_FreeBSD) || defined(__FreeBSD_kernel__)
     friend class USBProxyServiceFreeBSD;
 #endif
 };
Index: src/VBox/Main/src-client/ConsoleImpl2.cpp
===================================================================
--- src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 37995)
+++ src/VBox/Main/src-client/ConsoleImpl2.cpp	(working copy)
@@ -90,7 +90,7 @@
 #  include <linux/types.h>
 #  include <linux/if.h>
 #  include <linux/wireless.h>
-# elif defined(RT_OS_FREEBSD)
+# elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 #  include <unistd.h>
 #  include <sys/types.h>
 #  include <sys/ioctl.h>
@@ -2154,14 +2154,14 @@
                 }
 # endif
 #endif /* RT_OS_LINUX */
-#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(VBOX_WITH_SOLARIS_OSS)
+#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__) || defined(VBOX_WITH_SOLARIS_OSS)
                 case AudioDriverType_OSS:
                 {
                     InsertConfigString(pCfg, "AudioDriver", "oss");
                     break;
                 }
 #endif
-#ifdef RT_OS_FREEBSD
+#if defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 # ifdef VBOX_WITH_PULSE
                 case AudioDriverType_Pulse:
                 {
@@ -3780,7 +3780,7 @@
 
             case NetworkAttachmentType_Bridged:
             {
-#if (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)) && !defined(VBOX_WITH_NETFLT)
+#if (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)) && !defined(VBOX_WITH_NETFLT)
                 hrc = attachToTapInterface(aNetworkAdapter);
                 if (FAILED(hrc))
                 {
@@ -3989,8 +3989,8 @@
                 const char *pszTrunk = szTrunkName;
                 /* we're not releasing the INetCfg stuff here since we use it later to figure out whether it is wireless */
 
-# elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
-#  if defined(RT_OS_FREEBSD)
+# elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
+#  if defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
                 /*
                  * If we bridge to a tap interface open it the `old' direct way.
                  * This works and performs better than bridging a physical
@@ -4089,7 +4089,7 @@
                 }
                 else
                     Log(("Failed to open wireless socket\n"));
-# elif defined(RT_OS_FREEBSD)
+# elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
                 int iSock = socket(AF_INET, SOCK_DGRAM, 0);
                 if (iSock >= 0)
                 {
@@ -4207,7 +4207,7 @@
             /* NOTHING TO DO HERE */
 #elif defined(RT_OS_LINUX)
 /// @todo aleksey: is there anything to be done here?
-#elif defined(RT_OS_FREEBSD)
+#elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 /** @todo FreeBSD: Check out this later (HIF networking). */
 #else
 # error "Port me"
Index: src/VBox/Main/src-client/ConsoleImpl.cpp
===================================================================
--- src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 37995)
+++ src/VBox/Main/src-client/ConsoleImpl.cpp	(working copy)
@@ -29,7 +29,7 @@
 #   include <stdio.h>
 #   include <stdlib.h>
 #   include <string.h>
-#elif defined(RT_OS_FREEBSD)
+#elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 #   include <errno.h>
 #   include <sys/ioctl.h>
 #   include <sys/poll.h>
@@ -7832,7 +7832,7 @@
 #endif /* VBOX_WITH_USB */
 
 /* Note: FreeBSD needs this whether netflt is used or not. */
-#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
+#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__))
 /**
  * Helper function to handle host interface device creation and attachment.
  *
@@ -7949,7 +7949,7 @@
         }
     }
 
-# elif defined(RT_OS_FREEBSD)
+# elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
     /*
      * Set/obtain the tap interface.
      */
@@ -8067,7 +8067,7 @@
     LogFlowThisFunc(("returning %d\n", rc));
     return rc;
 }
-#endif /* (RT_OS_LINUX || RT_OS_FREEBSD) && !VBOX_WITH_NETFLT */
+#endif /* (RT_OS_LINUX || RT_OS_FREEBSD || __FreeBSD_kernel__) && !VBOX_WITH_NETFLT */
 
 /**
  * Called at power down to terminate host interface networking.
@@ -8100,11 +8100,11 @@
         pNetworkAdapter->COMGETTER(AttachmentType)(&attachment);
         if (attachment == NetworkAttachmentType_Bridged)
         {
-#if ((defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)) && !defined(VBOX_WITH_NETFLT))
+#if ((defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)) && !defined(VBOX_WITH_NETFLT))
             HRESULT rc2 = detachFromTapInterface(pNetworkAdapter);
             if (FAILED(rc2) && SUCCEEDED(rc))
                 rc = rc2;
-#endif /* (RT_OS_LINUX || RT_OS_FREEBSD) && !VBOX_WITH_NETFLT */
+#endif /* (RT_OS_LINUX || RT_OS_FREEBSD || __FreeBSD_kernel__) && !VBOX_WITH_NETFLT */
         }
     }
 
Index: src/VBox/Main/src-server/MachineImpl.cpp
===================================================================
--- src/VBox/Main/src-server/MachineImpl.cpp	(revision 37995)
+++ src/VBox/Main/src-server/MachineImpl.cpp	(working copy)
@@ -1587,7 +1587,7 @@
 STDMETHODIMP Machine::COMSETTER(MemoryBalloonSize)(ULONG memoryBalloonSize)
 {
     /* This must match GMMR0Init; currently we only support memory ballooning on all 64-bit hosts except Mac OS X */
-#if HC_ARCH_BITS == 64 && (defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD))
+#if HC_ARCH_BITS == 64 && (defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__))
     /* check limits */
     if (memoryBalloonSize >= VMMDEV_MAX_MEMORY_BALLOON(mHWData->mMemorySize))
         return setError(E_INVALIDARG,
@@ -10643,7 +10643,7 @@
                     E_FAIL);
 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
 # ifdef VBOX_WITH_NEW_SYS_V_KEYGEN
-#  if defined(RT_OS_FREEBSD) && (HC_ARCH_BITS == 64)
+#  if (defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)) && (HC_ARCH_BITS == 64)
     /** @todo Check that this still works correctly. */
     AssertCompileSize(key_t, 8);
 #  else
Index: src/VBox/HostDrivers/Support/SUPDrvIDC.h
===================================================================
--- src/VBox/HostDrivers/Support/SUPDrvIDC.h	(revision 37995)
+++ src/VBox/HostDrivers/Support/SUPDrvIDC.h	(working copy)
@@ -226,7 +226,7 @@
 #if defined(RT_OS_DARWIN)
 extern int VBOXCALL SUPDrvDarwinIDC(uint32_t iReq, PSUPDRVIDCREQHDR pReq);
 
-#elif defined(RT_OS_FREEBSD)
+#elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 extern int VBOXCALL SUPDrvFreeBSDIDC(uint32_t iReq, PSUPDRVIDCREQHDR pReq);
 
 #elif defined(RT_OS_LINUX)
Index: src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp
===================================================================
--- src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp	(revision 37995)
+++ src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp	(working copy)
@@ -62,7 +62,7 @@
 #  ifndef CAP_TO_MASK
 #   define CAP_TO_MASK(cap) RT_BIT(cap)
 #  endif
-# elif defined(RT_OS_FREEBSD)
+# elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 #  include <sys/param.h>
 #  include <sys/sysctl.h>
 # elif defined(RT_OS_SOLARIS)
@@ -317,7 +317,7 @@
      *
      * Darwin, OS/2 and Windows all have proper APIs for getting the program file name.
      */
-#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_SOLARIS)
+#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__) || defined(RT_OS_SOLARIS)
 # ifdef RT_OS_LINUX
     int cchLink = readlink("/proc/self/exe", &g_szSupLibHardenedExePath[0], sizeof(g_szSupLibHardenedExePath) - 1);
 
Index: src/VBox/HostDrivers/Support/SUPDrvInternal.h
===================================================================
--- src/VBox/HostDrivers/Support/SUPDrvInternal.h	(revision 37995)
+++ src/VBox/HostDrivers/Support/SUPDrvInternal.h	(working copy)
@@ -115,7 +115,7 @@
 
 #elif defined(RT_OS_OS2)
 
-#elif defined(RT_OS_FREEBSD)
+#elif defined(RT_OS_FREEBSD) || defined(__FreeBSD_kernel__)
 #   define memset  libkern_memset /** @todo these are just hacks to get it compiling, check out later. */
 #   define memcmp  libkern_memcmp
 #   define strchr  libkern_strchr
