Index: /trunk/include/iprt/nocrt/stdlib.h
===================================================================
--- /trunk/include/iprt/nocrt/stdlib.h	(revision 96069)
+++ /trunk/include/iprt/nocrt/stdlib.h	(revision 96070)
@@ -44,6 +44,6 @@
 typedef FNRTNOCRTATEXITCALLBACK *PFNRTNOCRTATEXITCALLBACK;
 #if defined(_MSC_VER) && defined(RT_WITHOUT_NOCRT_WRAPPERS) /* Clashes with compiler internal prototype or smth. */
-int          rtnocrt_atexit(PFNRTNOCRTATEXITCALLBACK) RT_NOEXCEPT;
-# define     atexit rtnocrt_atexit
+int          nocrt_atexit(PFNRTNOCRTATEXITCALLBACK) RT_NOEXCEPT;
+# define     atexit nocrt_atexit
 #else
 int          RT_NOCRT(atexit)(PFNRTNOCRTATEXITCALLBACK) RT_NOEXCEPT;
Index: /trunk/include/iprt/nocrt/unistd.h
===================================================================
--- /trunk/include/iprt/nocrt/unistd.h	(revision 96069)
+++ /trunk/include/iprt/nocrt/unistd.h	(revision 96070)
@@ -32,6 +32,7 @@
 #include <iprt/nocrt/sys/types.h>
 
+#ifdef IPRT_NO_CRT_FOR_3RD_PARTY
 
-#ifdef IPRT_NO_CRT_FOR_3RD_PARTY
+RT_C_DECLS_BEGIN
 
 int             RT_NOCRT(access)(const char *, int) RT_NOEXCEPT;
@@ -81,4 +82,6 @@
 # endif
 
+RT_C_DECLS_END
+
 #endif /* IPRT_NO_CRT_FOR_3RD_PARTY */
 
Index: /trunk/src/VBox/Runtime/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Runtime/Makefile.kmk	(revision 96069)
+++ /trunk/src/VBox/Runtime/Makefile.kmk	(revision 96070)
@@ -1800,4 +1800,11 @@
   	,$(RuntimeBaseR3_SOURCES)) \
        \
+  	common/file/nocrt-fstat.cpp \
+  	common/file/nocrt-isatty.cpp \
+  	common/file/nocrt-read.cpp \
+  	common/path/nocrt-unlink.cpp \
+  	common/rand/nocrt-rand.cpp \
+  	common/sort/nocrt-qsort.cpp \
+  	common/sort/nocrt-qsort_r.cpp \
   	common/string/nocrt-strdup.cpp \
   	common/string/nocrt-stricmp.cpp \
Index: /trunk/src/VBox/Runtime/common/compiler/vcc/atexit-vcc.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/compiler/vcc/atexit-vcc.cpp	(revision 96069)
+++ /trunk/src/VBox/Runtime/common/compiler/vcc/atexit-vcc.cpp	(revision 96070)
@@ -59,5 +59,5 @@
 
 /* Note! not using atexit here because it'll clash with built-in prototype.  */
-extern "C" int rtnocrt_atexit(PFNRTNOCRTATEXITCALLBACK pfnCallback) RT_NOEXCEPT
+extern "C" int nocrt_atexit(PFNRTNOCRTATEXITCALLBACK pfnCallback) RT_NOEXCEPT
 {
     AssertPtr(pfnCallback);
@@ -95,4 +95,5 @@
     return 0;
 }
+RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(atexit);
 
 
Index: /trunk/src/VBox/Runtime/common/file/nocrt-fstat.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/file/nocrt-fstat.cpp	(revision 96070)
+++ /trunk/src/VBox/Runtime/common/file/nocrt-fstat.cpp	(revision 96070)
@@ -0,0 +1,71 @@
+/* $Id$ */
+/** @file
+ * IPRT - No-CRT - fstat().
+ */
+
+/*
+ * Copyright (C) 2022 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define IPRT_NO_CRT_FOR_3RD_PARTY
+#include "internal/nocrt.h"
+#include <iprt/nocrt/sys/stat.h>
+#include <iprt/nocrt/errno.h>
+#include <iprt/errcore.h>
+#include <iprt/file.h>
+
+
+#undef fstat
+int RT_NOCRT(fstat)(int fd, struct RT_NOCRT(stat) *pStat)
+{
+    RTFILE hFile;
+    int rc = RTFileFromNative(&hFile, fd);
+    if (RT_SUCCESS(rc))
+    {
+        RTFSOBJINFO ObjInfo;
+        rc = RTFileQueryInfo(hFile, &ObjInfo, RTFSOBJATTRADD_UNIX);
+        if (RT_SUCCESS(rc))
+        {
+            pStat->st_ino       = ObjInfo.Attr.u.Unix.INodeId;
+            pStat->st_dev       = ObjInfo.Attr.u.Unix.INodeIdDevice;
+            pStat->st_rdev      = ObjInfo.Attr.u.Unix.Device;
+            pStat->st_mode      = ObjInfo.Attr.fMode;
+            pStat->st_link      = ObjInfo.Attr.u.Unix.cHardlinks;
+            pStat->st_uid       = ObjInfo.Attr.u.Unix.uid;
+            pStat->st_gid       = ObjInfo.Attr.u.Unix.gid;
+            pStat->st_size      = ObjInfo.cbObject;
+            pStat->st_blocks    = (ObjInfo.cbObject + 511) / 512;
+            pStat->st_blksize   = 16384; /* whatever */
+            pStat->st_birthtime = RTTimeSpecGetSeconds(&ObjInfo.BirthTime);
+            pStat->st_ctime     = RTTimeSpecGetSeconds(&ObjInfo.ChangeTime);
+            pStat->st_mtime     = RTTimeSpecGetSeconds(&ObjInfo.ModificationTime);
+            pStat->st_atime     = RTTimeSpecGetSeconds(&ObjInfo.AccessTime);
+            return 0;
+        }
+    }
+    errno = RTErrConvertToErrno(rc);
+    return -1;
+}
+RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(fstat);
+
Index: /trunk/src/VBox/Runtime/common/file/nocrt-isatty.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/file/nocrt-isatty.cpp	(revision 96070)
+++ /trunk/src/VBox/Runtime/common/file/nocrt-isatty.cpp	(revision 96070)
@@ -0,0 +1,62 @@
+/* $Id$ */
+/** @file
+ * IPRT - No-CRT - isatty().
+ */
+
+/*
+ * Copyright (C) 2022 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define IPRT_NO_CRT_FOR_3RD_PARTY
+#include "internal/nocrt.h"
+#include <iprt/nocrt/unistd.h>
+#include <iprt/nocrt/errno.h>
+#include <iprt/errcore.h>
+
+#ifdef RT_OS_WINDOWS
+# include <iprt/win/windows.h>
+#endif
+
+
+#undef isatty
+int RT_NOCRT(isatty)(int fd) RT_NOEXCEPT
+{
+#ifdef RT_OS_WINDOWS
+    HANDLE hNative = (HANDLE)(uintptr_t)(unsigned)fd;
+    DWORD  dwType = GetFileType(hNative);
+    if (dwType == FILE_TYPE_CHAR)
+        return 1;
+
+    if (dwType != FILE_TYPE_UNKNOWN)
+        errno = ENOTTY;
+    else
+        errno = RTErrConvertToErrno(RTErrConvertFromWin32(GetLastError()));
+    return 0;
+
+#else
+# error "port me"
+#endif
+}
+RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(isatty);
+
Index: /trunk/src/VBox/Runtime/common/file/nocrt-read.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/file/nocrt-read.cpp	(revision 96070)
+++ /trunk/src/VBox/Runtime/common/file/nocrt-read.cpp	(revision 96070)
@@ -0,0 +1,55 @@
+/* $Id$ */
+/** @file
+ * IPRT - No-CRT - read().
+ */
+
+/*
+ * Copyright (C) 2022 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define IPRT_NO_CRT_FOR_3RD_PARTY
+#include "internal/nocrt.h"
+#include <iprt/nocrt/unistd.h>
+#include <iprt/nocrt/errno.h>
+#include <iprt/errcore.h>
+#include <iprt/file.h>
+
+
+#undef read
+ssize_t RT_NOCRT(read)(int fd, void *pvBuf, size_t cbToRead) RT_NOEXCEPT
+{
+    RTFILE hFile;
+    int rc = RTFileFromNative(&hFile, fd);
+    if (RT_SUCCESS(rc))
+    {
+        size_t cbRead = 0;
+        rc = RTFileRead(hFile, pvBuf, cbToRead, &cbRead);
+        if (RT_SUCCESS(rc))
+            return cbRead;
+    }
+    errno = RTErrConvertToErrno(rc);
+    return -1;
+}
+RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(read);
+
Index: /trunk/src/VBox/Runtime/common/path/nocrt-unlink.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/path/nocrt-unlink.cpp	(revision 96070)
+++ /trunk/src/VBox/Runtime/common/path/nocrt-unlink.cpp	(revision 96070)
@@ -0,0 +1,49 @@
+/* $Id$ */
+/** @file
+ * IPRT - No-CRT - unlink().
+ */
+
+/*
+ * Copyright (C) 2022 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define IPRT_NO_CRT_FOR_3RD_PARTY
+#include "internal/nocrt.h"
+#include <iprt/nocrt/unistd.h>
+#include <iprt/nocrt/errno.h>
+#include <iprt/errcore.h>
+#include <iprt/path.h>
+
+
+#undef unlink
+int RT_NOCRT(unlink)(const char *pszPath) RT_NOEXCEPT
+{
+    int rc = RTPathUnlink(pszPath, 0 /*fUnlink*/);
+    if (RT_SUCCESS(rc))
+        return 0;
+    errno = RTErrConvertToErrno(rc);
+    return -1;
+}
+RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(unlink);
+
Index: /trunk/src/VBox/Runtime/common/rand/nocrt-rand.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/rand/nocrt-rand.cpp	(revision 96070)
+++ /trunk/src/VBox/Runtime/common/rand/nocrt-rand.cpp	(revision 96070)
@@ -0,0 +1,46 @@
+/* $Id$ */
+/** @file
+ * IPRT - No-CRT - rand().
+ */
+
+/*
+ * Copyright (C) 2022 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define IPRT_NO_CRT_FOR_3RD_PARTY
+#include "internal/nocrt.h"
+#include <iprt/nocrt/stdlib.h>
+#include <iprt/assertcompile.h>
+#include <iprt/rand.h>
+
+
+#undef rand
+int RT_NOCRT(rand)(void)
+{
+    /** @todo this isn't actually pseudo random, it mixes TSC into it.  */
+    AssertCompile(sizeof(int) <= sizeof(uint32_t));
+    return (int)RTRandU32();
+}
+RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(rand);
+
Index: /trunk/src/VBox/Runtime/common/sort/nocrt-qsort.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/sort/nocrt-qsort.cpp	(revision 96070)
+++ /trunk/src/VBox/Runtime/common/sort/nocrt-qsort.cpp	(revision 96070)
@@ -0,0 +1,60 @@
+/* $Id$ */
+/** @file
+ * IPRT - No-CRT - qsort().
+ */
+
+/*
+ * Copyright (C) 2022 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define IPRT_NO_CRT_FOR_3RD_PARTY
+#include "internal/nocrt.h"
+#include <iprt/nocrt/stdlib.h>
+#include <iprt/sort.h>
+
+
+#if !defined(RT_ARCH_AMD64) /* ASSUMING the regular calling convention */ \
+ && !defined(RT_ARCH_X86)   /* ASSUMING __cdecl, won't work for __stdcall or __fastcall. */
+# define NEED_COMPARE_WRAPPER
+/** @callback_method_impl{FNRTSORTCMP} */
+static int DECLCALLBACK(int) CompareWrapper(void const *pvElement1, void const *pvElement2, void *pvUser))
+{
+    int (*pfnCompare)(const void *pv1, const void *pv2) = (int (*)(const void *pv1, const void *pv2))(uintptr_t)pvUser;
+    return pfnCompare(pvElement1, pvElement2);
+}
+#endif
+
+#undef qsort
+void RT_NOCRT(qsort)(void *pvBase, size_t cEntries, size_t cbEntry,
+                     int (*pfnCompare)(const void *pv1, const void *pv2))
+{
+    /** @todo Implement and use RTSortQuick! */
+#ifdef NEED_COMPARE_WRAPPER
+    RTSortShell(pvBase, cEntries, cbEntry, CompareWrapper, (void *)(uintptr_t)pfnCompare);
+#else
+    RTSortShell(pvBase, cEntries, cbEntry, (PFNRTSORTCMP)pfnCompare, NULL);
+#endif
+}
+RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(qsort);
+
Index: /trunk/src/VBox/Runtime/common/sort/nocrt-qsort_r.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/sort/nocrt-qsort_r.cpp	(revision 96070)
+++ /trunk/src/VBox/Runtime/common/sort/nocrt-qsort_r.cpp	(revision 96070)
@@ -0,0 +1,47 @@
+/* $Id$ */
+/** @file
+ * IPRT - No-CRT - qsort_r().
+ */
+
+/*
+ * Copyright (C) 2022 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#define IPRT_NO_CRT_FOR_3RD_PARTY
+#include "internal/nocrt.h"
+#include <iprt/nocrt/stdlib.h>
+#include <iprt/sort.h>
+
+
+#undef qsort_r
+void RT_NOCRT(qsort_r)(void *pvBase, size_t cEntries, size_t cbEntry,
+                       int (*pfnCompare)(const void *pv1, const void *pv2, void *pvUser), void *pvUser)
+{
+    /** @todo Implement and use RTSortQuick! */
+    /* ASSUMES that we're using compatible calling conventions (x86: __cdecl, amd64: default). */
+    RTSortShell(pvBase, cEntries, cbEntry, (PFNRTSORTCMP)pfnCompare, pvUser);
+}
+RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(qsort_r);
+
+
