diff options
| author | Michael Meskes <meskes@debian.org> | 2011-01-20 11:21:45 +0100 |
|---|---|---|
| committer | Michael Meskes <meskes@debian.org> | 2011-01-20 11:21:45 +0100 |
| commit | 14ee89c73b263c9a9e6e5bd300ef05c1ed41742a (patch) | |
| tree | ba2010adc07bd73710310b25adb8428ea866e067 /src/VBox/Runtime | |
| parent | 361589e3ae692db27161410309b92c6b89e1ec6c (diff) | |
| download | virtualbox-14ee89c73b263c9a9e6e5bd300ef05c1ed41742a.tar.gz | |
Imported Upstream version 4.0.2-dfsgupstream/4.0.2-dfsg
Diffstat (limited to 'src/VBox/Runtime')
20 files changed, 431 insertions, 52 deletions
diff --git a/src/VBox/Runtime/Makefile.kmk b/src/VBox/Runtime/Makefile.kmk index 01ec30b75..e26027b57 100644 --- a/src/VBox/Runtime/Makefile.kmk +++ b/src/VBox/Runtime/Makefile.kmk @@ -1,4 +1,4 @@ -# $Id: Makefile.kmk 35182 2010-12-16 13:57:44Z vboxsync $ +# $Id: Makefile.kmk 35585 2011-01-17 14:20:13Z vboxsync $ ## @file # Sub-Makefile for the IPRT (IPRT). # @@ -32,7 +32,7 @@ ifdef VBOX_ONLY_ADDITIONS # Only build the additions, sort out the legacy names first. # LIBRARIES += RuntimeGuestR3 RuntimeGuestR3Shared RuntimeGuestR3Mini - LIBRARIES.win.amd64 += RuntimeGuestR3-x86 + LIBRARIES.win.amd64 += RuntimeGuestR3-x86 RuntimeGuestR3Shared-x86 ifdef VBOX_WITH_ADDITION_DRIVERS LIBRARIES += RuntimeGuestR0 #LIBRARIES.os2 += RuntimeGuestR0OS2Warp3 @@ -85,7 +85,7 @@ else # !VBOX_ONLY_ADDITIONS && !VBOX_ONLY_TESTSUITE && !VBOX_ONLY_DOCS endif ifdef VBOX_WITH_ADDITIONS LIBRARIES += RuntimeGuestR3 RuntimeGuestR3Shared RuntimeGuestR3Mini - LIBRARIES.win.amd64 += RuntimeGuestR3-x86 + LIBRARIES.win.amd64 += RuntimeGuestR3-x86 RuntimeGuestR3Shared-x86 ifdef VBOX_WITH_ADDITION_DRIVERS LIBRARIES += RuntimeGuestR0 endif @@ -364,6 +364,7 @@ RuntimeR3_SOURCES = \ common/string/simplepattern.cpp \ common/string/straprintf.cpp \ common/string/strformat.cpp \ + common/string/strformatnum.cpp \ common/string/strformatrt.cpp \ common/string/strformattype.cpp \ common/string/stringalloc.cpp \ @@ -1011,6 +1012,13 @@ RuntimeGuestR3Shared_INST = $(INST_ADDITIONS_LIB) # +# RuntimeGuestR3Shared-x86 - Same as RuntimeGuestR3Shared, except that it's targeting x86. +# +RuntimeGuestR3Shared-x86_EXTENDS := RuntimeGuestR3Shared +RuntimeGuestR3Shared-x86_BLD_TRG_ARCH := x86 + + +# # RuntimeGuestR3Mini - Minimal Guest Additions Runtime which does not require # initialization and can be linked into an .so. Intended # for X11 drivers, GRADD and similar. @@ -1072,6 +1080,7 @@ RuntimeGuestR3Mini_SOURCES = \ common/string/RTStrStr.cpp \ common/string/straprintf.cpp \ common/string/strformat.cpp \ + common/string/strformatnum.cpp \ common/string/strformatrt.cpp \ common/string/strformattype.cpp \ common/string/stringalloc.cpp \ @@ -1152,7 +1161,7 @@ RuntimeLnxHostR3_INCS = \ # # VBoxRT - Shared Object / DLL version. # -VBoxRT_TEMPLATE = VBoxR3Dll +VBoxRT_TEMPLATE = VBoxR3DllNoPic VBoxRT_SDKS = VBOX_OPENSSL VBOX_LIBXML2 VBOX_BOOST ifdef VBOX_WITH_LIBCURL VBoxRT_SDKS += VBOX_LIBCURL @@ -1273,7 +1282,7 @@ VBoxRTDummy_LIBS = $(PATH_BIN)/VBoxRT.so VBoxRTDummy_CLEAN= $(PATH_BIN)/VBoxRT.so BLDDIRS += $(PATH_BIN) -$(PATH_BIN)/VBoxRT.so: $$(TARGET_VBoxRT) | $$(dir $$@) +$(PATH_BIN)/VBoxRT.so: $$(VBoxRT_1_TARGET) | $$(dir $$@) $(INSTALL) $< $@ chcon -t texrel_shlib_t $@ || true @@ -1548,6 +1557,7 @@ RuntimeR0Drv_SOURCES = \ common/string/RTStrNLen.cpp \ common/string/RTStrNLenEx.cpp \ common/string/strformat.cpp \ + common/string/strformatnum.cpp \ common/string/strformatrt.cpp \ common/string/strformattype.cpp \ common/string/strprintf.cpp \ @@ -1874,6 +1884,7 @@ ifdef VBOX_WITH_RAW_MODE common/misc/sanity-c.c \ common/misc/sanity-cpp.cpp \ common/string/strformat.cpp \ + common/string/strformatnum.cpp \ common/string/strformatrt.cpp \ common/string/strformattype.cpp \ common/string/strncmp.cpp \ diff --git a/src/VBox/Runtime/common/alloc/heapoffset.cpp b/src/VBox/Runtime/common/alloc/heapoffset.cpp index e2b5d19e0..fd5d0e96d 100644 --- a/src/VBox/Runtime/common/alloc/heapoffset.cpp +++ b/src/VBox/Runtime/common/alloc/heapoffset.cpp @@ -1,4 +1,4 @@ -/* $Id: heapoffset.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */ +/* $Id: heapoffset.cpp 35525 2011-01-13 14:00:37Z vboxsync $ */ /** @file * IPRT - An Offset Based Heap. */ @@ -34,10 +34,10 @@ #include <iprt/assert.h> #include <iprt/asm.h> -#include <iprt/string.h> #include <iprt/err.h> #include <iprt/log.h> #include <iprt/param.h> +#include <iprt/string.h> #include "internal/magics.h" diff --git a/src/VBox/Runtime/common/alloc/heapsimple.cpp b/src/VBox/Runtime/common/alloc/heapsimple.cpp index fe7c95f64..3377e6597 100644 --- a/src/VBox/Runtime/common/alloc/heapsimple.cpp +++ b/src/VBox/Runtime/common/alloc/heapsimple.cpp @@ -1,4 +1,4 @@ -/* $Id: heapsimple.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */ +/* $Id: heapsimple.cpp 35525 2011-01-13 14:00:37Z vboxsync $ */ /** @file * IPRT - A Simple Heap. */ @@ -34,9 +34,9 @@ #include <iprt/assert.h> #include <iprt/asm.h> -#include <iprt/string.h> #include <iprt/err.h> #include <iprt/log.h> +#include <iprt/string.h> #include <iprt/param.h> #include "internal/magics.h" diff --git a/src/VBox/Runtime/common/checksum/manifest-file.cpp b/src/VBox/Runtime/common/checksum/manifest-file.cpp index 77ac56d92..602c99d49 100644 --- a/src/VBox/Runtime/common/checksum/manifest-file.cpp +++ b/src/VBox/Runtime/common/checksum/manifest-file.cpp @@ -1,4 +1,4 @@ -/* $Id: manifest-file.cpp 34381 2010-11-25 15:49:11Z vboxsync $ */ +/* $Id: manifest-file.cpp 35351 2010-12-27 17:04:17Z vboxsync $ */ /** @file * IPRT - Manifest, the bits with file dependencies */ @@ -82,4 +82,3 @@ RTDECL(int) RTManifestWriteStandardToFile(RTMANIFEST hManifest, const char *pszF return rc; } - diff --git a/src/VBox/Runtime/common/checksum/manifest3.cpp b/src/VBox/Runtime/common/checksum/manifest3.cpp index 975a6b919..cf06cd064 100644 --- a/src/VBox/Runtime/common/checksum/manifest3.cpp +++ b/src/VBox/Runtime/common/checksum/manifest3.cpp @@ -1,4 +1,4 @@ -/* $Id: manifest3.cpp 34537 2010-11-30 18:11:51Z vboxsync $ */ +/* $Id: manifest3.cpp 35351 2010-12-27 17:04:17Z vboxsync $ */ /** @file * IPRT - Manifest, the bits with the most dependencies. */ @@ -548,5 +548,3 @@ RTDECL(int) RTManifestEntryAddIoStream(RTMANIFEST hManifest, RTVFSIOSTREAM hVfsI return rc; } - - diff --git a/src/VBox/Runtime/common/misc/sanity.h b/src/VBox/Runtime/common/misc/sanity.h index 4783c4ab1..97c7dc077 100644 --- a/src/VBox/Runtime/common/misc/sanity.h +++ b/src/VBox/Runtime/common/misc/sanity.h @@ -1,4 +1,4 @@ -/* $Id: sanity.h 28800 2010-04-27 08:22:32Z vboxsync $ */ +/* $Id: sanity.h 35512 2011-01-12 17:50:12Z vboxsync $ */ /** @file * IPRT - Setup Sanity Checks, C and C++. */ @@ -208,4 +208,8 @@ AssertCompileSize(RTUINT16U, 2); AssertCompileSize(RTUINT32U, 4); AssertCompileSize(RTUINT64U, 8); AssertCompileSize(RTUINT128U, 16); +/*AssertCompileSize(RTFLOAT32U, 8);*/ +AssertCompileSize(RTFLOAT64U, 8); +AssertCompileSize(RTFLOAT80U, 10); +/*AssertCompileSize(RTFLOAT128U, 16);*/ diff --git a/src/VBox/Runtime/common/string/ministring.cpp b/src/VBox/Runtime/common/string/ministring.cpp index 38178bf21..16729c6d3 100644 --- a/src/VBox/Runtime/common/string/ministring.cpp +++ b/src/VBox/Runtime/common/string/ministring.cpp @@ -1,4 +1,4 @@ -/* $Id: ministring.cpp 35128 2010-12-15 12:38:41Z vboxsync $ */ +/* $Id: ministring.cpp 35567 2011-01-14 14:16:45Z vboxsync $ */ /** @file * IPRT - Mini C++ string class. * @@ -223,7 +223,7 @@ void MiniString::findReplace(char cFind, char cReplace) } } -MiniString MiniString::substr(size_t pos /*= 0*/, size_t n /*= npos*/) +MiniString MiniString::substrCP(size_t pos /*= 0*/, size_t n /*= npos*/) const { MiniString ret; @@ -255,13 +255,16 @@ MiniString MiniString::substr(size_t pos /*= 0*/, size_t n /*= npos*/) return ret; // return empty string on bad encoding size_t cbCopy = psz - pFirst; - ret.reserve(cbCopy + 1); // may throw bad_alloc + if (cbCopy) + { + ret.reserve(cbCopy + 1); // may throw bad_alloc #ifndef RT_EXCEPTIONS_ENABLED - AssertRelease(capacity() >= cbCopy + 1); + AssertRelease(capacity() >= cbCopy + 1); #endif - memcpy(ret.m_psz, pFirst, cbCopy); - ret.m_cch = cbCopy; - ret.m_psz[cbCopy] = '\0'; + memcpy(ret.m_psz, pFirst, cbCopy); + ret.m_cch = cbCopy; + ret.m_psz[cbCopy] = '\0'; + } } } } diff --git a/src/VBox/Runtime/common/string/strformatnum.cpp b/src/VBox/Runtime/common/string/strformatnum.cpp new file mode 100644 index 000000000..171cd1918 --- /dev/null +++ b/src/VBox/Runtime/common/string/strformatnum.cpp @@ -0,0 +1,252 @@ +/* $Id: strformatnum.cpp 35585 2011-01-17 14:20:13Z vboxsync $ */ +/** @file + * IPRT - String Formatter, Single Numbers. + */ + +/* + * Copyright (C) 2010 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 LOG_GROUP RTLOGGROUP_STRING +#include <iprt/string.h> +#include "internal/iprt.h" + +#include <iprt/assert.h> +#include "internal/string.h" + + +RTDECL(ssize_t) RTStrFormatU8(char *pszBuf, size_t cbBuf, uint8_t u8Value, unsigned int uiBase, + signed int cchWidth, signed int cchPrecision, uint32_t fFlags) +{ + fFlags &= ~RTSTR_F_BIT_MASK; + fFlags |= RTSTR_F_8BIT; + + ssize_t cchRet; + if (cbBuf >= 64) + cchRet = RTStrFormatNumber(pszBuf, u8Value, uiBase, cchWidth, cchPrecision, fFlags); + else + { + char szTmp[64]; + cchRet = RTStrFormatNumber(szTmp, u8Value, uiBase, cchWidth, cchPrecision, fFlags); + if ((size_t)cchRet <= cbBuf) + memcpy(pszBuf, szTmp, cchRet + 1); + else + { + if (cbBuf) + { + memcpy(pszBuf, szTmp, cbBuf - 1); + pszBuf[cbBuf - 1] = '\0'; + } + cchRet = VERR_BUFFER_OVERFLOW; + } + } + return cchRet; +} + + +RTDECL(ssize_t) RTStrFormatU16(char *pszBuf, size_t cbBuf, uint16_t u16Value, unsigned int uiBase, + signed int cchWidth, signed int cchPrecision, uint32_t fFlags) +{ + fFlags &= ~RTSTR_F_BIT_MASK; + fFlags |= RTSTR_F_16BIT; + + ssize_t cchRet; + if (cbBuf >= 64) + cchRet = RTStrFormatNumber(pszBuf, u16Value, uiBase, cchWidth, cchPrecision, fFlags); + else + { + char szTmp[64]; + cchRet = RTStrFormatNumber(szTmp, u16Value, uiBase, cchWidth, cchPrecision, fFlags); + if ((size_t)cchRet <= cbBuf) + memcpy(pszBuf, szTmp, cchRet + 1); + else + { + if (cbBuf) + { + memcpy(pszBuf, szTmp, cbBuf - 1); + pszBuf[cbBuf - 1] = '\0'; + } + cchRet = VERR_BUFFER_OVERFLOW; + } + } + return cchRet; +} + + +RTDECL(ssize_t) RTStrFormatU32(char *pszBuf, size_t cbBuf, uint32_t u32Value, unsigned int uiBase, + signed int cchWidth, signed int cchPrecision, uint32_t fFlags) +{ + fFlags &= ~RTSTR_F_BIT_MASK; + fFlags |= RTSTR_F_32BIT; + + ssize_t cchRet; + if (cbBuf >= 64) + cchRet = RTStrFormatNumber(pszBuf, u32Value, uiBase, cchWidth, cchPrecision, fFlags); + else + { + char szTmp[64]; + cchRet = RTStrFormatNumber(szTmp, u32Value, uiBase, cchWidth, cchPrecision, fFlags); + if ((size_t)cchRet <= cbBuf) + memcpy(pszBuf, szTmp, cchRet + 1); + else + { + if (cbBuf) + { + memcpy(pszBuf, szTmp, cbBuf - 1); + pszBuf[cbBuf - 1] = '\0'; + } + cchRet = VERR_BUFFER_OVERFLOW; + } + } + return cchRet; +} + + +RTDECL(ssize_t) RTStrFormatU64(char *pszBuf, size_t cbBuf, uint64_t u64Value, unsigned int uiBase, + signed int cchWidth, signed int cchPrecision, uint32_t fFlags) +{ + fFlags &= ~RTSTR_F_BIT_MASK; + fFlags |= RTSTR_F_64BIT; + + ssize_t cchRet; + if (cbBuf >= 64) + cchRet = RTStrFormatNumber(pszBuf, u64Value, uiBase, cchWidth, cchPrecision, fFlags); + else + { + char szTmp[64]; + cchRet = RTStrFormatNumber(szTmp, u64Value, uiBase, cchWidth, cchPrecision, fFlags); + if ((size_t)cchRet <= cbBuf) + memcpy(pszBuf, szTmp, cchRet + 1); + else + { + if (cbBuf) + { + memcpy(pszBuf, szTmp, cbBuf - 1); + pszBuf[cbBuf - 1] = '\0'; + } + cchRet = VERR_BUFFER_OVERFLOW; + } + } + return cchRet; +} + + +RTDECL(ssize_t) RTStrFormatU128(char *pszBuf, size_t cbBuf, PCRTUINT128U pu128, unsigned int uiBase, + signed int cchWidth, signed int cchPrecision, uint32_t fFlags) +{ + if (uiBase != 16) + fFlags |= RTSTR_F_SPECIAL; + fFlags &= ~RTSTR_F_BIT_MASK; + + char szTmp[64+32]; + size_t cchFirst = RTStrFormatNumber(szTmp, pu128->s.Hi, 16, 0, 0, fFlags | RTSTR_F_64BIT); + size_t cchSecond = RTStrFormatNumber(&szTmp[cchFirst], pu128->s.Lo, 16, 8, 0, + (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL); + int rc = RTStrCopy(pszBuf, cbBuf, szTmp); + if (RT_FAILURE(rc)) + return rc; + return cchFirst + cchSecond; +} + + +RTDECL(ssize_t) RTStrFormatR80u2(char *pszBuf, size_t cbBuf, PCRTFLOAT80U2 pr80Value, signed int cchWidth, + signed int cchPrecision, uint32_t fFlags) +{ + char szTmp[160]; + + char *pszTmp = szTmp; + if (pr80Value->s.fSign) + *pszTmp++ = '-'; + else + *pszTmp++ = '+'; + + if (pr80Value->s.uExponent == 0) + { + if ( !pr80Value->sj64.u63Fraction + && pr80Value->sj64.fInteger) + *pszTmp++ = '0'; + /* else: Denormal, handled way below. */ + } + else if (pr80Value->sj64.uExponent == UINT16_C(0x7fff)) + { + /** @todo Figure out Pseudo inf/nan... */ + if (pr80Value->sj64.fInteger) + *pszTmp++ = 'P'; + if (pr80Value->sj64.u63Fraction == 0) + { + *pszTmp++ = 'I'; + *pszTmp++ = 'n'; + *pszTmp++ = 'f'; + } + else + { + *pszTmp++ = 'N'; + *pszTmp++ = 'a'; + *pszTmp++ = 'N'; + } + } + if (pszTmp != &szTmp[1]) + *pszTmp = '\0'; + else + { + *pszTmp++ = pr80Value->sj64.fInteger ? '1' : '0'; + *pszTmp++ = 'm'; + pszTmp += RTStrFormatNumber(pszTmp, pr80Value->sj64.u63Fraction, 16, 2+16, 0, + RTSTR_F_SPECIAL | RTSTR_F_ZEROPAD | RTSTR_F_64BIT); + + *pszTmp++ = 'e'; + pszTmp += RTStrFormatNumber(pszTmp, (int32_t)pr80Value->sj64.uExponent - 16383, 10, 0, 0, + RTSTR_F_ZEROPAD | RTSTR_F_32BIT | RTSTR_F_VALSIGNED); + } + + /* + * Copy out the result. + */ + ssize_t cchRet = pszTmp - &szTmp[0]; + if ((size_t)cchRet <= cbBuf) + memcpy(pszBuf, szTmp, cchRet + 1); + else + { + if (cbBuf) + { + memcpy(pszBuf, szTmp, cbBuf - 1); + pszBuf[cbBuf - 1] = '\0'; + } + cchRet = VERR_BUFFER_OVERFLOW; + } + return cchRet; +} + + +RTDECL(ssize_t) RTStrFormatR80(char *pszBuf, size_t cbBuf, PCRTFLOAT80U pr80Value, signed int cchWidth, + signed int cchPrecision, uint32_t fFlags) +{ + RTFLOAT80U2 r80ValueU2; + RT_ZERO(r80ValueU2); + r80ValueU2.s.fSign = pr80Value->s.fSign; + r80ValueU2.s.uExponent = pr80Value->s.uExponent; + r80ValueU2.s.u64Mantissa = pr80Value->s.u64Mantissa; + return RTStrFormatR80u2(pszBuf, cbBuf, &r80ValueU2, cchWidth, cchPrecision, fFlags); +} + diff --git a/src/VBox/Runtime/common/string/strspace.cpp b/src/VBox/Runtime/common/string/strspace.cpp index 304035f40..809c867f8 100644 --- a/src/VBox/Runtime/common/string/strspace.cpp +++ b/src/VBox/Runtime/common/string/strspace.cpp @@ -1,4 +1,4 @@ -/* $Id: strspace.cpp 33540 2010-10-28 09:27:05Z vboxsync $ */ +/* $Id: strspace.cpp 35464 2011-01-10 16:30:27Z vboxsync $ */ /** @file * IPRT - Unique String Spaces. */ @@ -96,6 +96,19 @@ DECLINLINE(uint32_t) sdbm(const char *str, size_t *pcch) return hash; } +DECLINLINE(uint32_t) sdbmN(const char *str, size_t cchMax, size_t *pcch) +{ + uint8_t *pu8 = (uint8_t *)str; + uint32_t hash = 0; + int c; + + while ((c = *pu8++) && cchMax-- > 0) + hash = c + (hash << 6) + (hash << 16) - hash; + + *pcch = (uintptr_t)pu8 - (uintptr_t)str - 1; + return hash; +} + /** * Inserts a string into a unique string space. @@ -199,6 +212,34 @@ RTDECL(PRTSTRSPACECORE) RTStrSpaceGet(PRTSTRSPACE pStrSpace, const char *pszStri RT_EXPORT_SYMBOL(RTStrSpaceGet); +/** + * Gets a string from a unique string space. + * + * @returns Pointer to the string node. + * @returns NULL if the string was not found in the string space. + * @param pStrSpace The space to insert it into. + * @param pszString The string to get. + * @param cchMax The max string length to evaluate. Passing + * RTSTR_MAX is ok and makes it behave just like + * RTStrSpaceGet. + */ +RTDECL(PRTSTRSPACECORE) RTStrSpaceGetN(PRTSTRSPACE pStrSpace, const char *pszString, size_t cchMax) +{ + size_t cchString; + KAVLKEY Key = sdbmN(pszString, cchMax, &cchString); + PRTSTRSPACECORE pCur = KAVL_FN(Get)(pStrSpace, Key); + if (!pCur) + return NULL; + + /* Linear search. */ + for (; pCur; pCur = pCur->pList) + if ( pCur->cchString == cchString + && !memcmp(pCur->pszString, pszString, cchString)) + return pCur; + return NULL; +} +RT_EXPORT_SYMBOL(RTStrSpaceGetN); + /** * Enumerates the string space. diff --git a/src/VBox/Runtime/common/zip/tar.cpp b/src/VBox/Runtime/common/zip/tar.cpp index 574ab7eac..d59dcb963 100644 --- a/src/VBox/Runtime/common/zip/tar.cpp +++ b/src/VBox/Runtime/common/zip/tar.cpp @@ -1,4 +1,4 @@ -/* $Id: tar.cpp 35122 2010-12-15 11:28:30Z vboxsync $ */ +/* $Id: tar.cpp 35351 2010-12-27 17:04:17Z vboxsync $ */ /** @file * IPRT - Tar archive I/O. */ @@ -228,10 +228,11 @@ DECLINLINE(void) rtTarSizeToRec(PRTTARRECORD pRecord, uint64_t cbSize) DECLINLINE(uint64_t) rtTarRecToSize(PRTTARRECORD pRecord) { int64_t cbSize = 0; - if (pRecord->h.size[0] & 0x80) + if (pRecord->h.size[0] & 0x80) { size_t cchField = sizeof(pRecord->h.size); unsigned char const *puchField = (unsigned char const *)pRecord->h.size; + /* * The first byte has the bit 7 set to indicate base-256, while bit 6 * is the signed bit. Bits 5:0 are the most significant value bits. @@ -240,6 +241,7 @@ DECLINLINE(uint64_t) rtTarRecToSize(PRTTARRECORD pRecord) cbSize = (cbSize << 6) | (*puchField & 0x3f); cchField--; puchField++; + /* * The remaining bytes are used in full. */ @@ -253,7 +255,8 @@ DECLINLINE(uint64_t) rtTarRecToSize(PRTTARRECORD pRecord) } cbSize = (cbSize << 8) | *puchField++; } - }else + } + else RTStrToInt64Full(pRecord->h.size, 8, &cbSize); if (cbSize < 0) diff --git a/src/VBox/Runtime/common/zip/tarcmd.cpp b/src/VBox/Runtime/common/zip/tarcmd.cpp index c2fb84e53..45a104731 100644 --- a/src/VBox/Runtime/common/zip/tarcmd.cpp +++ b/src/VBox/Runtime/common/zip/tarcmd.cpp @@ -1,4 +1,4 @@ -/* $Id: tarcmd.cpp 34179 2010-11-18 15:49:17Z vboxsync $ */ +/* $Id: tarcmd.cpp 35351 2010-12-27 17:04:17Z vboxsync $ */ /** @file * IPRT - TAR Command. */ @@ -667,4 +667,3 @@ RTDECL(RTEXITCODE) RTZipTarCmd(unsigned cArgs, char **papszArgs) } } - diff --git a/src/VBox/Runtime/include/internal/lockvalidator.h b/src/VBox/Runtime/include/internal/lockvalidator.h index 2cc9b5cca..0cc7796f2 100644 --- a/src/VBox/Runtime/include/internal/lockvalidator.h +++ b/src/VBox/Runtime/include/internal/lockvalidator.h @@ -1,4 +1,4 @@ -/* $Id: lockvalidator.h 28800 2010-04-27 08:22:32Z vboxsync $ */ +/* $Id: lockvalidator.h 35499 2011-01-12 08:33:45Z vboxsync $ */ /** @file * IPRT - Internal RTLockValidator header. */ @@ -29,7 +29,6 @@ #include <iprt/types.h> #include <iprt/lockvalidator.h> -#include "internal/lockvalidator.h" RT_C_DECLS_BEGIN diff --git a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c index 2679aa53f..2f40746c8 100644 --- a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c +++ b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c @@ -1,4 +1,4 @@ -/* $Revision: 35165 $ */ +/* $Revision: 35603 $ */ /** @file * IPRT - Ring-0 Memory Objects, Linux. */ @@ -198,9 +198,9 @@ static int rtR0MemObjLinuxAllocPages(PRTR0MEMOBJLNX *ppMemLnx, RTR0MEMOBJTYPE en if (cPages > 255) { -# ifdef __GFP_NORETRY - /* Not available in Linux 2.4.0 */ - fFlagsLnx |= __GFP_NORETRY; +# ifdef __GFP_REPEAT + /* Try hard to allocate the memory, but the allocation attempt might fail. */ + fFlagsLnx |= __GFP_REPEAT; # endif # ifdef __GFP_NOMEMALLOC /* Introduced with Linux 2.6.12: Don't use emergency reserves */ diff --git a/src/VBox/Runtime/r3/posix/process-creation-posix.cpp b/src/VBox/Runtime/r3/posix/process-creation-posix.cpp index 908d869fb..9a57cbcf2 100644 --- a/src/VBox/Runtime/r3/posix/process-creation-posix.cpp +++ b/src/VBox/Runtime/r3/posix/process-creation-posix.cpp @@ -1,4 +1,4 @@ -/* $Id: process-creation-posix.cpp 34708 2010-12-03 17:30:45Z vboxsync $ */ +/* $Id: process-creation-posix.cpp 35558 2011-01-14 13:30:33Z vboxsync $ */ /** @file * IPRT - Process Creation, POSIX. */ @@ -355,15 +355,20 @@ RTR3DECL(int) RTProcCreateEx(const char *pszExec, const char * const *papszArg if (fFlags & RTPROC_FLAGS_DETACHED) { # ifdef RT_OS_SOLARIS - int templateFd = rtSolarisContractPreFork(); - if (templateFd == -1) - return VERR_OPEN_FAILED; + int templateFd = -1; + if (!(fFlags & RTPROC_FLAGS_SAME_CONTRACT)) + { + templateFd = rtSolarisContractPreFork(); + if (templateFd == -1) + return VERR_OPEN_FAILED; + } # endif /* RT_OS_SOLARIS */ pid = fork(); if (!pid) { # ifdef RT_OS_SOLARIS - rtSolarisContractPostForkChild(templateFd); + if (!(fFlags & RTPROC_FLAGS_SAME_CONTRACT)) + rtSolarisContractPostForkChild(templateFd); # endif /* RT_OS_SOLARIS */ setsid(); /* see comment above */ @@ -373,7 +378,8 @@ RTR3DECL(int) RTProcCreateEx(const char *pszExec, const char * const *papszArg else { #ifdef RT_OS_SOLARIS - rtSolarisContractPostForkParent(templateFd, pid); + if (!(fFlags & RTPROC_FLAGS_SAME_CONTRACT)) + rtSolarisContractPostForkParent(templateFd, pid); #endif /* RT_OS_SOLARIS */ if (pid > 0) { @@ -656,6 +662,9 @@ RTR3DECL(int) RTProcDaemonizeUsingFork(bool fNoChDir, bool fNoClose, const cha /* Create new session, fix up the standard file descriptors and the * current working directory. */ + /** @todo r=klaus the webservice uses this function and assumes that the + * contract id of the daemon is the same as that of the original process. + * Whenever this code is changed this must still remain possible. */ pid_t newpgid = setsid(); int SavedErrno = errno; if (rcSigAct != -1) diff --git a/src/VBox/Runtime/r3/win/fileaio-win.cpp b/src/VBox/Runtime/r3/win/fileaio-win.cpp index 15a1eae74..062ceb049 100644 --- a/src/VBox/Runtime/r3/win/fileaio-win.cpp +++ b/src/VBox/Runtime/r3/win/fileaio-win.cpp @@ -1,4 +1,4 @@ -/* $Id: fileaio-win.cpp 33540 2010-10-28 09:27:05Z vboxsync $ */ +/* $Id: fileaio-win.cpp 35408 2011-01-05 15:43:05Z vboxsync $ */ /** @file * IPRT - File async I/O, native implementation for the Windows host platform. */ @@ -455,7 +455,12 @@ RTDECL(int) RTFileAioCtxWait(RTFILEAIOCTX hAioCtx, size_t cMinReqs, RTMSINTERVAL if (fSucceeded) pReqInt->Rc = VINF_SUCCESS; else - pReqInt->Rc = RTErrConvertFromWin32(GetLastError()); + { + DWORD errCode = GetLastError(); + pReqInt->Rc = RTErrConvertFromWin32(errCode); + if (pReqInt->Rc == VERR_UNRESOLVED_ERROR) + LogRel(("AIO/win: Request %#p returned rc=%Rrc (native %u\n)", pReqInt, pReqInt->Rc, errCode)); + } pahReqs[cRequestsCompleted++] = (RTFILEAIOREQ)pReqInt; diff --git a/src/VBox/Runtime/testcase/Makefile.kmk b/src/VBox/Runtime/testcase/Makefile.kmk index 6e2917e30..4913e399c 100644 --- a/src/VBox/Runtime/testcase/Makefile.kmk +++ b/src/VBox/Runtime/testcase/Makefile.kmk @@ -1,4 +1,4 @@ -# $Id: Makefile.kmk 34626 2010-12-02 16:44:03Z vboxsync $ +# $Id: Makefile.kmk 35337 2010-12-27 13:31:04Z vboxsync $ ## @file # Sub-Makefile for the IPRT testcases. # @@ -284,14 +284,14 @@ ifdef VBOX_WITH_RAW_MODE $(PATH_LIB)/RuntimeRC$(VBOX_SUFF_LIB) ifeq ($(VBOX_LDR_FMT32),pe) tstLdrObj_LIBS += \ - $(PATH_LIB)/VMMGCBuiltin$(VBOX_SUFF_LIB) + $(PATH_LIB)/VMMRCBuiltin$(VBOX_SUFF_LIB) endif # PE ifeq ($(VBOX_LDR_FMT32),elf) tstLdrObj_LDFLAGS = -e Entrypoint endif ifeq ($(VBOX_LDR_FMT32),lx) tstLdrObj_LIBS += \ - $(PATH_LIB)/VMMGCBuiltin$(VBOX_SUFF_LIB) + $(PATH_LIB)/VMMRCBuiltin$(VBOX_SUFF_LIB) endif endif # VBOX_WITH_RAW_MODE diff --git a/src/VBox/Runtime/testcase/tstIprtMiniString.cpp b/src/VBox/Runtime/testcase/tstIprtMiniString.cpp index 06f6b993e..68e167921 100644 --- a/src/VBox/Runtime/testcase/tstIprtMiniString.cpp +++ b/src/VBox/Runtime/testcase/tstIprtMiniString.cpp @@ -1,4 +1,4 @@ -/* $Id: tstIprtMiniString.cpp 33862 2010-11-08 17:07:49Z vboxsync $ */ +/* $Id: tstIprtMiniString.cpp 35568 2011-01-14 14:24:53Z vboxsync $ */ /** @file * IPRT Testcase - iprt::MiniString. */ @@ -210,6 +210,50 @@ static void test1(RTTEST hTest) iprt::MiniString SubStr15(SubStrBase, 2, 5); CHECK_EQUAL(SubStr15, "cdef"); + /* substr() and substrCP() functions */ + iprt::MiniString strTest(""); + CHECK_EQUAL(strTest.substr(0), ""); + CHECK_EQUAL(strTest.substrCP(0), ""); + CHECK_EQUAL(strTest.substr(1), ""); + CHECK_EQUAL(strTest.substrCP(1), ""); + + /* now let's have some non-ASCII to chew on */ + strTest = "abcdefßäbcdef"; + // 13 codepoints, but 15 bytes (excluding null terminator); + // "ß" and "ä" consume two bytes each + CHECK_EQUAL(strTest.substr(0), strTest.c_str()); + CHECK_EQUAL(strTest.substrCP(0), strTest.c_str()); + + CHECK_EQUAL(strTest.substr(2), "cdefßäbcdef"); + CHECK_EQUAL(strTest.substrCP(2), "cdefßäbcdef"); + + CHECK_EQUAL(strTest.substr(2, 2), "cd"); + CHECK_EQUAL(strTest.substrCP(2, 2), "cd"); + + CHECK_EQUAL(strTest.substr(6), "ßäbcdef"); + CHECK_EQUAL(strTest.substrCP(6), "ßäbcdef"); + + CHECK_EQUAL(strTest.substr(6, 2), "ß"); // UTF-8 "ß" consumes two bytes + CHECK_EQUAL(strTest.substrCP(6, 1), "ß"); + + CHECK_EQUAL(strTest.substr(8), "äbcdef"); // UTF-8 "ß" consumes two bytes + CHECK_EQUAL(strTest.substrCP(7), "äbcdef"); + + CHECK_EQUAL(strTest.substr(8, 3), "äb"); // UTF-8 "ä" consumes two bytes + CHECK_EQUAL(strTest.substrCP(7, 2), "äb"); + + CHECK_EQUAL(strTest.substr(14, 1), "f"); + CHECK_EQUAL(strTest.substrCP(12, 1), "f"); + + CHECK_EQUAL(strTest.substr(15, 1), ""); + CHECK_EQUAL(strTest.substrCP(13, 1), ""); + + CHECK_EQUAL(strTest.substr(16, 1), ""); + CHECK_EQUAL(strTest.substrCP(15, 1), ""); + + /* and check cooperation with find() */ + size_t pos = strTest.find("ß"); + CHECK_EQUAL(strTest.substr(pos), "ßäbcdef"); /* special constructor and assignment arguments */ iprt::MiniString StrCtor1(""); diff --git a/src/VBox/Runtime/testcase/tstLdrObj.cpp b/src/VBox/Runtime/testcase/tstLdrObj.cpp index 9dd6a5528..747c3ee57 100644 --- a/src/VBox/Runtime/testcase/tstLdrObj.cpp +++ b/src/VBox/Runtime/testcase/tstLdrObj.cpp @@ -1,4 +1,4 @@ -/* $Id: tstLdrObj.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */ +/* $Id: tstLdrObj.cpp 35346 2010-12-27 16:13:13Z vboxsync $ */ /** @file * IPRT - RTLdr test object. * @@ -38,7 +38,7 @@ # error "not IN_RC!" #endif #include <VBox/dis.h> -#include <VBox/vm.h> +#include <VBox/vmm/vm.h> #include <iprt/string.h> diff --git a/src/VBox/Runtime/testcase/tstRTThreadPoke.cpp b/src/VBox/Runtime/testcase/tstRTThreadPoke.cpp index a52f35d30..2e2938e4d 100644 --- a/src/VBox/Runtime/testcase/tstRTThreadPoke.cpp +++ b/src/VBox/Runtime/testcase/tstRTThreadPoke.cpp @@ -1,4 +1,4 @@ -/* $Id: tstRTThreadPoke.cpp 34174 2010-11-18 14:52:35Z vboxsync $ */ +/* $Id: tstRTThreadPoke.cpp 35351 2010-12-27 17:04:17Z vboxsync $ */ /** @file * IPRT Testcase - RTThreadPoke. */ @@ -77,4 +77,3 @@ int main() #endif } - diff --git a/src/VBox/Runtime/win/errmsgwin.cpp b/src/VBox/Runtime/win/errmsgwin.cpp index 8c3353458..fed8a0a82 100644 --- a/src/VBox/Runtime/win/errmsgwin.cpp +++ b/src/VBox/Runtime/win/errmsgwin.cpp @@ -1,10 +1,10 @@ -/* $Id: errmsgwin.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */ +/* $Id: errmsgwin.cpp 35445 2011-01-10 11:05:23Z vboxsync $ */ /** @file * IPRT - Status code messages. */ /* - * Copyright (C) 2006-2007 Oracle Corporation + * Copyright (C) 2006-2011 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -80,6 +80,19 @@ RTDECL(PCRTWINERRMSG) RTErrWinGet(long rc) if (g_aStatusMsgs[i].iCode == rc) return &g_aStatusMsgs[i]; + /* The g_aStatusMsgs table contains a wild mix of error codes with and + * without included facility and severity. So the chance is high that there + * was no exact match. Try to find a non-exact match, and include the + * actual value in case we pick the wrong entry. Better than always using + * the "Unknown Status" case. */ + for (i = 0; i < RT_ELEMENTS(g_aStatusMsgs); i++) + if (g_aStatusMsgs[i].iCode == HRESULT_CODE(rc)) + { + int32_t iMsg = (ASMAtomicIncU32(&g_iUnknownMsgs) - 1) % RT_ELEMENTS(g_aUnknownMsgs); + RTStrPrintf(&g_aszUnknownStr[iMsg][0], sizeof(g_aszUnknownStr[iMsg]), "%s 0x%X", g_aStatusMsgs[i].pszDefine, rc); + return &g_aUnknownMsgs[iMsg]; + } + /* * Need to use the temporary stuff. */ |
