summaryrefslogtreecommitdiff
path: root/include/iprt
diff options
context:
space:
mode:
Diffstat (limited to 'include/iprt')
-rw-r--r--include/iprt/aiomgr.h155
-rw-r--r--include/iprt/alloc.h2
-rw-r--r--include/iprt/alloca.h2
-rw-r--r--include/iprt/asm-amd64-x86.h248
-rw-r--r--include/iprt/asm.h178
-rw-r--r--include/iprt/asmdefs.mac108
-rw-r--r--include/iprt/assert.h123
-rw-r--r--include/iprt/avl.h68
-rw-r--r--include/iprt/base64.h2
-rw-r--r--include/iprt/buildconfig.h2
-rw-r--r--include/iprt/cdefs.h384
-rw-r--r--include/iprt/cidr.h13
-rw-r--r--include/iprt/circbuf.h2
-rw-r--r--include/iprt/cpp/list.h506
-rw-r--r--include/iprt/cpp/ministring.h6
-rw-r--r--include/iprt/cpp/mtlist.h37
-rw-r--r--include/iprt/cpp/utils.h34
-rw-r--r--include/iprt/cpp/xml.h512
-rw-r--r--include/iprt/crc.h2
-rw-r--r--include/iprt/critsect.h435
-rw-r--r--include/iprt/ctype.h2
-rw-r--r--include/iprt/dbg.h372
-rw-r--r--include/iprt/dir.h59
-rw-r--r--include/iprt/dvm.h2
-rw-r--r--include/iprt/env.h14
-rw-r--r--include/iprt/err.h156
-rw-r--r--include/iprt/err.mac71
-rw-r--r--include/iprt/err.sed2
-rw-r--r--include/iprt/file.h92
-rw-r--r--include/iprt/formats/Makefile.kup0
-rw-r--r--include/iprt/formats/codeview.h82
-rw-r--r--include/iprt/formats/hfs.h677
-rw-r--r--include/iprt/formats/mach-o.h626
-rw-r--r--include/iprt/formats/mz.mac56
-rw-r--r--include/iprt/formats/pe.mac722
-rw-r--r--include/iprt/formats/xar.h68
-rw-r--r--include/iprt/fs.h8
-rw-r--r--include/iprt/getopt.h24
-rw-r--r--include/iprt/handletable.h13
-rw-r--r--include/iprt/heap.h2
-rw-r--r--include/iprt/http.h169
-rw-r--r--include/iprt/initterm.h11
-rw-r--r--include/iprt/isofs.h2
-rw-r--r--include/iprt/ldr.h405
-rw-r--r--include/iprt/ldrlazy.h102
-rw-r--r--include/iprt/linux/sysfs.h2
-rw-r--r--include/iprt/list.h47
-rw-r--r--include/iprt/localipc.h8
-rw-r--r--include/iprt/lockvalidator.h69
-rw-r--r--include/iprt/log.h18
-rw-r--r--include/iprt/mangling.h147
-rw-r--r--include/iprt/manifest.h40
-rw-r--r--include/iprt/md5.h2
-rw-r--r--include/iprt/mem.h20
-rw-r--r--include/iprt/memcache.h12
-rw-r--r--include/iprt/memobj.h2
-rw-r--r--include/iprt/mempool.h2
-rw-r--r--include/iprt/memtracker.h2
-rw-r--r--include/iprt/message.h2
-rw-r--r--include/iprt/mp.h24
-rw-r--r--include/iprt/net.h77
-rw-r--r--include/iprt/nocrt/amd64/fenv.h2
-rw-r--r--include/iprt/nocrt/amd64/math.h2
-rw-r--r--include/iprt/nocrt/compiler/compiler.h2
-rw-r--r--include/iprt/nocrt/compiler/gcc.h2
-rw-r--r--include/iprt/nocrt/compiler/msc.h2
-rw-r--r--include/iprt/nocrt/fenv.h2
-rw-r--r--include/iprt/nocrt/inttypes.h2
-rw-r--r--include/iprt/nocrt/limits.h2
-rw-r--r--include/iprt/nocrt/math.h2
-rw-r--r--include/iprt/nocrt/setjmp.h2
-rw-r--r--include/iprt/nocrt/stdarg.h2
-rw-r--r--include/iprt/nocrt/stddef.h2
-rw-r--r--include/iprt/nocrt/stdlib.h2
-rw-r--r--include/iprt/nocrt/string.h2
-rw-r--r--include/iprt/nocrt/x86/fenv.h2
-rw-r--r--include/iprt/nocrt/x86/math.h2
-rw-r--r--include/iprt/once.h86
-rw-r--r--include/iprt/param.h2
-rw-r--r--include/iprt/path.h500
-rw-r--r--include/iprt/pipe.h2
-rw-r--r--include/iprt/power.h2
-rw-r--r--include/iprt/process.h2
-rw-r--r--include/iprt/queueatomic.h123
-rw-r--r--include/iprt/rand.h2
-rw-r--r--include/iprt/runtime-loader.h6
-rw-r--r--include/iprt/runtime.h2
-rw-r--r--include/iprt/s3.h2
-rw-r--r--include/iprt/semaphore.h2
-rw-r--r--include/iprt/sg.h17
-rw-r--r--include/iprt/sha.h27
-rw-r--r--include/iprt/sort.h2
-rw-r--r--include/iprt/spinlock.h4
-rw-r--r--include/iprt/stdint.h6
-rw-r--r--include/iprt/strcache.h73
-rw-r--r--include/iprt/stream.h2
-rw-r--r--include/iprt/string.h27
-rw-r--r--include/iprt/symlink.h2
-rw-r--r--include/iprt/system.h12
-rw-r--r--include/iprt/table.h2
-rw-r--r--include/iprt/tar.h4
-rw-r--r--include/iprt/tcp.h34
-rw-r--r--include/iprt/test.h227
-rw-r--r--include/iprt/thread.h109
-rw-r--r--include/iprt/time.h28
-rw-r--r--include/iprt/types.h135
-rw-r--r--include/iprt/uni.h32
-rw-r--r--include/iprt/uuid.h2
-rw-r--r--include/iprt/vfs.h28
-rw-r--r--include/iprt/vfslowlevel.h2
-rw-r--r--include/iprt/win/lazy-dbghelp.h137
-rw-r--r--include/iprt/x86.h402
-rw-r--r--include/iprt/x86.mac146
-rw-r--r--include/iprt/x86extra.mac118
-rw-r--r--include/iprt/zip.h51
115 files changed, 8447 insertions, 975 deletions
diff --git a/include/iprt/aiomgr.h b/include/iprt/aiomgr.h
new file mode 100644
index 00000000..651d29ee
--- /dev/null
+++ b/include/iprt/aiomgr.h
@@ -0,0 +1,155 @@
+/** @file
+ * IPRT - Async I/O manager.
+ */
+
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef ___iprt_aiomgr_h
+#define ___iprt_aiomgr_h
+
+#include <iprt/cdefs.h>
+#include <iprt/types.h>
+#include <iprt/sg.h>
+
+/**
+ * Completion callback.
+ *
+ * @returns nothing.
+ * @param hAioMgrFile File handle the completed request was for.
+ * @param rcReq Status code of the completed request.
+ * @param pvUser Opaque user data given when the request was initiated.
+ */
+typedef DECLCALLBACK(void) FNRTAIOMGRREQCOMPLETE(RTAIOMGRFILE hAioMgrFile, int rcReq, void *pvUser);
+/** Pointer to a completion callback. */
+typedef FNRTAIOMGRREQCOMPLETE *PFNRTAIOMGRREQCOMPLETE;
+
+RT_C_DECLS_BEGIN
+
+/**
+ * Create a new async I/O manager.
+ *
+ * @returns IPRT statuse code.
+ * @param phAioMgr Where to store the new async I/O manager handle on success.
+ * @param cReqsMax Maximum number of async I/O requests expected.
+ * Use UINT32_MAX to make it grow dynamically when required.
+ */
+RTDECL(int) RTAioMgrCreate(PRTAIOMGR phAioMgr, uint32_t cReqsMax);
+
+/**
+ * Retain a async I/O manager handle.
+ *
+ * @returns New reference count on success, UINT32_MAX on failure.
+ * @param hAioMgr The async I/O manager to retain.
+ */
+RTDECL(uint32_t) RTAioMgrRetain(RTAIOMGR hAioMgr);
+
+/**
+ * Releases a async I/O manager handle.
+ *
+ * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
+ * @param hAioMgr The async I/O manager to release.
+ */
+RTDECL(uint32_t) RTAioMgrRelease(RTAIOMGR hAioMgr);
+
+/**
+ * Assign a given file handle to the given async I/O manager.
+ *
+ * @returns IPRT status code.
+ * @param hAioMgr Async I/O manager handle.
+ * @param hFile File handle to assign.
+ * @param pfnReqComplete Callback to execute whenever a request for the
+ * file completed.
+ * @param phAioMgrFile Where to store the newly created async I/O manager
+ * handle on success.
+ * @param pvUser Opaque user data for this file handle.
+ *
+ * @note This function increases the reference count of the given async I/O manager
+ * by 1.
+ */
+RTDECL(int) RTAioMgrFileCreate(RTAIOMGR hAioMgr, RTFILE hFile, PFNRTAIOMGRREQCOMPLETE pfnReqComplete,
+ void *pvUser, PRTAIOMGRFILE phAioMgrFile);
+
+/**
+ * Retain a async I/O manager file handle.
+ *
+ * @returns New reference count on success, UINT32_MAX on failure.
+ * @param hAioMgrFile The file handle to retain.
+ */
+RTDECL(uint32_t) RTAioMgrFileRetain(RTAIOMGRFILE hAioMgrFile);
+
+/**
+ * Releases a async I/O manager file handle.
+ *
+ * @returns New reference count on success (0 if closed), UINT32_MAX on failure.
+ * @param hAioMgrFile The file handle to release.
+ */
+RTDECL(uint32_t) RTAioMgrFileRelease(RTAIOMGRFILE hAioMgrFile);
+
+/**
+ * Return opaque user data passed on creation.
+ *
+ * @returns Opaque user data or NULL if the handle is invalid.
+ * @param hAioMgrFile The file handle.
+ */
+RTDECL(void *) RTAioMgrFileGetUser(RTAIOMGRFILE hAioMgrFile);
+
+/**
+ * Initiate a read request from the given file handle.
+ *
+ * @returns IPRT status code.
+ * @param hAioMgrFile The file handle to read from.
+ * @param off Start offset to read from.
+ * @param pSgBuf S/G buffer to read into. The buffer is advanced
+ * by the amount of data to read.
+ * @param cbRead Number of bytes to read.
+ * @param pvUser Opaque user data given in the completion callback.
+ */
+RTDECL(int) RTAioMgrFileRead(RTAIOMGRFILE hAioMgrFile, RTFOFF off,
+ PRTSGBUF pSgBuf, size_t cbRead, void *pvUser);
+
+/**
+ * Initiate a write request to the given file handle.
+ *
+ * @returns IPRT status code.
+ * @param hAioMgrFile The file handle to write to.
+ * @param off Start offset to write to.
+ * @param pSgBuf S/G buffer to read from. The buffer is advanced
+ * by the amount of data to write.
+ * @param cbWrite Number of bytes to write.
+ * @param pvUser Opaque user data given in the completion callback.
+ */
+RTDECL(int) RTAioMgrFileWrite(RTAIOMGRFILE hAioMgrFile, RTFOFF off,
+ PRTSGBUF pSgBuf, size_t cbWrite, void *pvUser);
+
+/**
+ * Initiates a flush request for the given file handle.
+ *
+ * @returns IPRT statuse code.
+ * @param hAioMgrFile The file handle to write to.
+ * @param pvUser Opaque user data given in the completion callback.
+ */
+RTDECL(int) RTAioMgrFileFlush(RTAIOMGRFILE hAioMgrFile, void *pvUser);
+
+RT_C_DECLS_END
+
+#endif
+
diff --git a/include/iprt/alloc.h b/include/iprt/alloc.h
index e30b7f87..783c1898 100644
--- a/include/iprt/alloc.h
+++ b/include/iprt/alloc.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/alloca.h b/include/iprt/alloca.h
index 4aa00e6a..c47771cd 100644
--- a/include/iprt/alloca.h
+++ b/include/iprt/alloca.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/asm-amd64-x86.h b/include/iprt/asm-amd64-x86.h
index 22efb441..b0f0c5bc 100644
--- a/include/iprt/asm-amd64-x86.h
+++ b/include/iprt/asm-amd64-x86.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -68,6 +68,10 @@
# pragma intrinsic(__readcr8)
# pragma intrinsic(__writecr8)
# endif
+# if RT_INLINE_ASM_USES_INTRIN >= 15
+# pragma intrinsic(__readeflags)
+# pragma intrinsic(__writeeflags)
+# endif
#endif
@@ -350,10 +354,75 @@ DECLINLINE(RTSEL) ASMGetTR(void)
/**
+ * Get the LDTR register.
+ * @returns LDTR.
+ */
+#if RT_INLINE_ASM_EXTERNAL
+DECLASM(RTSEL) ASMGetLDTR(void);
+#else
+DECLINLINE(RTSEL) ASMGetLDTR(void)
+{
+ RTSEL SelLDTR;
+# if RT_INLINE_ASM_GNU_STYLE
+ __asm__ __volatile__("sldt %w0\n\t" : "=r" (SelLDTR));
+# else
+ __asm
+ {
+ sldt ax
+ mov [SelLDTR], ax
+ }
+# endif
+ return SelLDTR;
+}
+#endif
+
+
+/**
+ * Get the access rights for the segment selector.
+ *
+ * @returns The access rights on success or ~0U on failure.
+ * @param uSel The selector value.
+ *
+ * @remarks Using ~0U for failure is chosen because valid access rights always
+ * have bits 0:7 as 0 (on both Intel & AMD).
+ */
+#if RT_INLINE_ASM_EXTERNAL
+DECLASM(uint32_t) ASMGetSegAttr(uint32_t uSel);
+#else
+DECLINLINE(uint32_t) ASMGetSegAttr(uint32_t uSel)
+{
+ uint32_t uAttr;
+ /* LAR only accesses 16-bit of the source operand, but eax for the
+ destination operand is required for getting the full 32-bit access rights. */
+# if RT_INLINE_ASM_GNU_STYLE
+ __asm__ __volatile__("lar %1, %%eax\n\t"
+ "jz done%=\n\t"
+ "movl $0xffffffff, %%eax\n\t"
+ "done%=:\n\t"
+ "movl %%eax, %0\n\t"
+ : "=r" (uAttr)
+ : "r" (uSel)
+ : "cc", "%eax");
+# else
+ __asm
+ {
+ lar eax, [uSel]
+ jz done
+ mov eax, 0ffffffffh
+ done:
+ mov [uAttr], eax
+ }
+# endif
+ return uAttr;
+}
+#endif
+
+
+/**
* Get the [RE]FLAGS register.
* @returns [RE]FLAGS.
*/
-#if RT_INLINE_ASM_EXTERNAL
+#if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < 15
DECLASM(RTCCUINTREG) ASMGetFlags(void);
#else
DECLINLINE(RTCCUINTREG) ASMGetFlags(void)
@@ -369,6 +438,8 @@ DECLINLINE(RTCCUINTREG) ASMGetFlags(void)
"popl %0\n\t"
: "=r" (uFlags));
# endif
+# elif RT_INLINE_ASM_USES_INTRIN >= 15
+ uFlags = __readeflags();
# else
__asm
{
@@ -390,7 +461,7 @@ DECLINLINE(RTCCUINTREG) ASMGetFlags(void)
* Set the [RE]FLAGS register.
* @param uFlags The new [RE]FLAGS value.
*/
-#if RT_INLINE_ASM_EXTERNAL
+#if RT_INLINE_ASM_EXTERNAL && RT_INLINE_ASM_USES_INTRIN < 15
DECLASM(void) ASMSetFlags(RTCCUINTREG uFlags);
#else
DECLINLINE(void) ASMSetFlags(RTCCUINTREG uFlags)
@@ -405,6 +476,8 @@ DECLINLINE(void) ASMSetFlags(RTCCUINTREG uFlags)
"popfl\n\t"
: : "g" (uFlags));
# endif
+# elif RT_INLINE_ASM_USES_INTRIN >= 15
+ __writeeflags(uFlags);
# else
__asm
{
@@ -524,8 +597,8 @@ DECLINLINE(void) ASMCpuId(uint32_t uOperator, void *pvEAX, void *pvEBX, void *pv
/**
- * Performs the cpuid instruction returning all registers.
- * Some subfunctions of cpuid take ECX as additional parameter (currently known for EAX=4)
+ * Performs the CPUID instruction with EAX and ECX input returning ALL output
+ * registers.
*
* @param uOperator CPUID operation (eax).
* @param uIdxECX ecx index
@@ -535,7 +608,7 @@ DECLINLINE(void) ASMCpuId(uint32_t uOperator, void *pvEAX, void *pvEBX, void *pv
* @param pvEDX Where to store edx.
* @remark We're using void pointers to ease the use of special bitfield structures and such.
*/
-#if RT_INLINE_ASM_EXTERNAL && !RT_INLINE_ASM_USES_INTRIN
+#if RT_INLINE_ASM_EXTERNAL || RT_INLINE_ASM_USES_INTRIN
DECLASM(void) ASMCpuId_Idx_ECX(uint32_t uOperator, uint32_t uIdxECX, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX);
#else
DECLINLINE(void) ASMCpuId_Idx_ECX(uint32_t uOperator, uint32_t uIdxECX, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX)
@@ -568,8 +641,7 @@ DECLINLINE(void) ASMCpuId_Idx_ECX(uint32_t uOperator, uint32_t uIdxECX, void *pv
# elif RT_INLINE_ASM_USES_INTRIN
int aInfo[4];
- /* ??? another intrinsic ??? */
- __cpuid(aInfo, uOperator);
+ __cpuidex(aInfo, uOperator, uIdxECX);
*(uint32_t *)pvEAX = aInfo[0];
*(uint32_t *)pvEBX = aInfo[1];
*(uint32_t *)pvECX = aInfo[2];
@@ -602,6 +674,23 @@ DECLINLINE(void) ASMCpuId_Idx_ECX(uint32_t uOperator, uint32_t uIdxECX, void *pv
/**
+ * CPUID variant that initializes all 4 registers before the CPUID instruction.
+ *
+ * @returns The EAX result value.
+ * @param uOperator CPUID operation (eax).
+ * @param uInitEBX The value to assign EBX prior to the CPUID instruction.
+ * @param uInitECX The value to assign ECX prior to the CPUID instruction.
+ * @param uInitEDX The value to assign EDX prior to the CPUID instruction.
+ * @param pvEAX Where to store eax. Optional.
+ * @param pvEBX Where to store ebx. Optional.
+ * @param pvECX Where to store ecx. Optional.
+ * @param pvEDX Where to store edx. Optional.
+ */
+DECLASM(uint32_t) ASMCpuIdExSlow(uint32_t uOperator, uint32_t uInitEBX, uint32_t uInitECX, uint32_t uInitEDX,
+ void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX);
+
+
+/**
* Performs the cpuid instruction returning ecx and edx.
*
* @param uOperator CPUID operation (eax).
@@ -979,7 +1068,7 @@ DECLINLINE(bool) ASMIsIntelCpu(void)
/**
- * Tests if it a authentic AMD CPU based on the ASMCpuId(0) output.
+ * Tests if it an authentic AMD CPU based on the ASMCpuId(0) output.
*
* @returns true/false.
* @param uEBX EBX return from ASMCpuId(0)
@@ -1009,6 +1098,71 @@ DECLINLINE(bool) ASMIsAmdCpu(void)
/**
+ * Tests if it a centaur hauling VIA CPU based on the ASMCpuId(0) output.
+ *
+ * @returns true/false.
+ * @param uEBX EBX return from ASMCpuId(0).
+ * @param uECX ECX return from ASMCpuId(0).
+ * @param uEDX EDX return from ASMCpuId(0).
+ */
+DECLINLINE(bool) ASMIsViaCentaurCpuEx(uint32_t uEBX, uint32_t uECX, uint32_t uEDX)
+{
+ return uEBX == UINT32_C(0x746e6543)
+ && uECX == UINT32_C(0x736c7561)
+ && uEDX == UINT32_C(0x48727561);
+}
+
+
+/**
+ * Tests if this is a centaur hauling VIA CPU.
+ *
+ * @returns true/false.
+ * @remarks ASSUMES that cpuid is supported by the CPU.
+ */
+DECLINLINE(bool) ASMIsViaCentaurCpu(void)
+{
+ uint32_t uEAX, uEBX, uECX, uEDX;
+ ASMCpuId(0, &uEAX, &uEBX, &uECX, &uEDX);
+ return ASMIsAmdCpuEx(uEBX, uECX, uEDX);
+}
+
+
+/**
+ * Checks whether ASMCpuId_EAX(0x00000000) indicates a valid range.
+ *
+ *
+ * @returns true/false.
+ * @param uEAX The EAX value of CPUID leaf 0x00000000.
+ *
+ * @note This only succeeds if there are at least two leaves in the range.
+ * @remarks The upper range limit is just some half reasonable value we've
+ * picked out of thin air.
+ */
+DECLINLINE(bool) ASMIsValidStdRange(uint32_t uEAX)
+{
+ return uEAX >= UINT32_C(0x00000001) && uEAX <= UINT32_C(0x000fffff);
+}
+
+
+/**
+ * Checks whether ASMCpuId_EAX(0x80000000) indicates a valid range.
+ *
+ * This only succeeds if there are at least two leaves in the range.
+ *
+ * @returns true/false.
+ * @param uEAX The EAX value of CPUID leaf 0x80000000.
+ *
+ * @note This only succeeds if there are at least two leaves in the range.
+ * @remarks The upper range limit is just some half reasonable value we've
+ * picked out of thin air.
+ */
+DECLINLINE(bool) ASMIsValidExtRange(uint32_t uEAX)
+{
+ return uEAX >= UINT32_C(0x80000001) && uEAX <= UINT32_C(0x800fffff);
+}
+
+
+/**
* Extracts the CPU family from ASMCpuId(1) or ASMCpuId(0x80000001)
*
* @returns Family.
@@ -1612,6 +1766,82 @@ DECLINLINE(void) ASMWrMsr(uint32_t uRegister, uint64_t u64Val)
/**
+ * Reads a machine specific register, extended version (for AMD).
+ *
+ * @returns Register content.
+ * @param uRegister Register to read.
+ * @param uXDI RDI/EDI value.
+ */
+#if RT_INLINE_ASM_EXTERNAL
+DECLASM(uint64_t) ASMRdMsrEx(uint32_t uRegister, RTCCUINTREG uXDI);
+#else
+DECLINLINE(uint64_t) ASMRdMsrEx(uint32_t uRegister, RTCCUINTREG uXDI)
+{
+ RTUINT64U u;
+# if RT_INLINE_ASM_GNU_STYLE
+ __asm__ __volatile__("rdmsr\n\t"
+ : "=a" (u.s.Lo),
+ "=d" (u.s.Hi)
+ : "c" (uRegister),
+ "D" (uXDI));
+
+# else
+ __asm
+ {
+ mov ecx, [uRegister]
+ xchg edi, [uXDI]
+ rdmsr
+ mov [u.s.Lo], eax
+ mov [u.s.Hi], edx
+ xchg edi, [uXDI]
+ }
+# endif
+
+ return u.u;
+}
+#endif
+
+
+/**
+ * Writes a machine specific register, extended version (for AMD).
+ *
+ * @returns Register content.
+ * @param uRegister Register to write to.
+ * @param uXDI RDI/EDI value.
+ * @param u64Val Value to write.
+ */
+#if RT_INLINE_ASM_EXTERNAL
+DECLASM(void) ASMWrMsrEx(uint32_t uRegister, RTCCUINTREG uXDI, uint64_t u64Val);
+#else
+DECLINLINE(void) ASMWrMsrEx(uint32_t uRegister, RTCCUINTREG uXDI, uint64_t u64Val)
+{
+ RTUINT64U u;
+
+ u.u = u64Val;
+# if RT_INLINE_ASM_GNU_STYLE
+ __asm__ __volatile__("wrmsr\n\t"
+ ::"a" (u.s.Lo),
+ "d" (u.s.Hi),
+ "c" (uRegister),
+ "D" (uXDI));
+
+# else
+ __asm
+ {
+ mov ecx, [uRegister]
+ xchg edi, [uXDI]
+ mov edx, [u.s.Hi]
+ mov eax, [u.s.Lo]
+ wrmsr
+ xchg edi, [uXDI]
+ }
+# endif
+}
+#endif
+
+
+
+/**
* Reads low part of a machine specific register.
*
* @returns Register content.
diff --git a/include/iprt/asm.h b/include/iprt/asm.h
index abaef3a0..92db9484 100644
--- a/include/iprt/asm.h
+++ b/include/iprt/asm.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -2992,6 +2992,8 @@ DECLINLINE(void) ASMAtomicOrS64(int64_t volatile *pi64, int64_t i64)
{
ASMAtomicOrU64((uint64_t volatile *)pi64, i64);
}
+
+
/**
* Atomically And an unsigned 32-bit value, ordered.
*
@@ -3085,6 +3087,180 @@ DECLINLINE(void) ASMAtomicAndS64(int64_t volatile *pi64, int64_t i64)
}
+/**
+ * Atomically OR an unsigned 32-bit value, unordered but interrupt safe.
+ *
+ * @param pu32 Pointer to the pointer variable to OR u32 with.
+ * @param u32 The value to OR *pu32 with.
+ */
+#if RT_INLINE_ASM_EXTERNAL
+DECLASM(void) ASMAtomicUoOrU32(uint32_t volatile *pu32, uint32_t u32);
+#else
+DECLINLINE(void) ASMAtomicUoOrU32(uint32_t volatile *pu32, uint32_t u32)
+{
+# if RT_INLINE_ASM_GNU_STYLE
+ __asm__ __volatile__("orl %1, %0\n\t"
+ : "=m" (*pu32)
+ : "ir" (u32),
+ "m" (*pu32));
+# else
+ __asm
+ {
+ mov eax, [u32]
+# ifdef RT_ARCH_AMD64
+ mov rdx, [pu32]
+ or [rdx], eax
+# else
+ mov edx, [pu32]
+ or [edx], eax
+# endif
+ }
+# endif
+}
+#endif
+
+
+/**
+ * Atomically OR a signed 32-bit value, unordered.
+ *
+ * @param pi32 Pointer to the pointer variable to OR u32 with.
+ * @param i32 The value to OR *pu32 with.
+ */
+DECLINLINE(void) ASMAtomicUoOrS32(int32_t volatile *pi32, int32_t i32)
+{
+ ASMAtomicUoOrU32((uint32_t volatile *)pi32, i32);
+}
+
+
+/**
+ * Atomically OR an unsigned 64-bit value, unordered.
+ *
+ * @param pu64 Pointer to the pointer variable to OR u64 with.
+ * @param u64 The value to OR *pu64 with.
+ */
+#if RT_INLINE_ASM_EXTERNAL
+DECLASM(void) ASMAtomicUoOrU64(uint64_t volatile *pu64, uint64_t u64);
+#else
+DECLINLINE(void) ASMAtomicUoOrU64(uint64_t volatile *pu64, uint64_t u64)
+{
+# if RT_INLINE_ASM_GNU_STYLE && defined(RT_ARCH_AMD64)
+ __asm__ __volatile__("orq %1, %q0\n\t"
+ : "=m" (*pu64)
+ : "r" (u64),
+ "m" (*pu64));
+# else
+ for (;;)
+ {
+ uint64_t u64Old = ASMAtomicUoReadU64(pu64);
+ uint64_t u64New = u64Old | u64;
+ if (ASMAtomicCmpXchgU64(pu64, u64New, u64Old))
+ break;
+ ASMNopPause();
+ }
+# endif
+}
+#endif
+
+
+/**
+ * Atomically Or a signed 64-bit value, unordered.
+ *
+ * @param pi64 Pointer to the pointer variable to OR u64 with.
+ * @param i64 The value to OR *pu64 with.
+ */
+DECLINLINE(void) ASMAtomicUoOrS64(int64_t volatile *pi64, int64_t i64)
+{
+ ASMAtomicUoOrU64((uint64_t volatile *)pi64, i64);
+}
+
+
+/**
+ * Atomically And an unsigned 32-bit value, unordered.
+ *
+ * @param pu32 Pointer to the pointer variable to AND u32 with.
+ * @param u32 The value to AND *pu32 with.
+ */
+#if RT_INLINE_ASM_EXTERNAL
+DECLASM(void) ASMAtomicUoAndU32(uint32_t volatile *pu32, uint32_t u32);
+#else
+DECLINLINE(void) ASMAtomicUoAndU32(uint32_t volatile *pu32, uint32_t u32)
+{
+# if RT_INLINE_ASM_GNU_STYLE
+ __asm__ __volatile__("andl %1, %0\n\t"
+ : "=m" (*pu32)
+ : "ir" (u32),
+ "m" (*pu32));
+# else
+ __asm
+ {
+ mov eax, [u32]
+# ifdef RT_ARCH_AMD64
+ mov rdx, [pu32]
+ and [rdx], eax
+# else
+ mov edx, [pu32]
+ and [edx], eax
+# endif
+ }
+# endif
+}
+#endif
+
+
+/**
+ * Atomically And a signed 32-bit value, unordered.
+ *
+ * @param pi32 Pointer to the pointer variable to AND i32 with.
+ * @param i32 The value to AND *pi32 with.
+ */
+DECLINLINE(void) ASMAtomicUoAndS32(int32_t volatile *pi32, int32_t i32)
+{
+ ASMAtomicUoAndU32((uint32_t volatile *)pi32, (uint32_t)i32);
+}
+
+
+/**
+ * Atomically And an unsigned 64-bit value, unordered.
+ *
+ * @param pu64 Pointer to the pointer variable to AND u64 with.
+ * @param u64 The value to AND *pu64 with.
+ */
+#if RT_INLINE_ASM_EXTERNAL
+DECLASM(void) ASMAtomicUoAndU64(uint64_t volatile *pu64, uint64_t u64);
+#else
+DECLINLINE(void) ASMAtomicUoAndU64(uint64_t volatile *pu64, uint64_t u64)
+{
+# if RT_INLINE_ASM_GNU_STYLE && defined(RT_ARCH_AMD64)
+ __asm__ __volatile__("andq %1, %0\n\t"
+ : "=m" (*pu64)
+ : "r" (u64),
+ "m" (*pu64));
+# else
+ for (;;)
+ {
+ uint64_t u64Old = ASMAtomicUoReadU64(pu64);
+ uint64_t u64New = u64Old & u64;
+ if (ASMAtomicCmpXchgU64(pu64, u64New, u64Old))
+ break;
+ ASMNopPause();
+ }
+# endif
+}
+#endif
+
+
+/**
+ * Atomically And a signed 64-bit value, unordered.
+ *
+ * @param pi64 Pointer to the pointer variable to AND i64 with.
+ * @param i64 The value to AND *pi64 with.
+ */
+DECLINLINE(void) ASMAtomicUoAndS64(int64_t volatile *pi64, int64_t i64)
+{
+ ASMAtomicUoAndU64((uint64_t volatile *)pi64, (uint64_t)i64);
+}
+
+
/** @def RT_ASM_PAGE_SIZE
* We try avoid dragging in iprt/param.h here.
diff --git a/include/iprt/asmdefs.mac b/include/iprt/asmdefs.mac
index 665c674b..0b363a56 100644
--- a/include/iprt/asmdefs.mac
+++ b/include/iprt/asmdefs.mac
@@ -3,7 +3,7 @@
;
;
-; Copyright (C) 2006-2007 Oracle Corporation
+; Copyright (C) 2006-2012 Oracle Corporation
;
; This file is part of VirtualBox Open Source Edition (OSE), as
; available from http://www.virtualbox.org. This file is free software;
@@ -72,6 +72,11 @@
%define RT_BIT(bit) (1 << bit)
;;
+; Makes a 32-bit unsigned (not type safe, but whatever) out of four byte values.
+%define RT_MAKE_U32_FROM_U8(b0, b1, b2, b3) ( (b3 << 24) | (b2 << 16) | (b1 << 8) | b0 )
+
+
+;;
; Align code, pad with INT3.
%define ALIGNCODE(alignment) align alignment, db 0cch
@@ -94,17 +99,19 @@
;;
; Mangles the given name so it can be referenced using DECLASM() in the
; C/C++ world.
-%ifdef RT_ARCH_X86
- %ifdef RT_OS_OS2
- %define NAME(name) _ %+ NAME_OVERLOAD(name)
+%ifndef ASM_FORMAT_BIN
+ %ifdef RT_ARCH_X86
+ %ifdef RT_OS_OS2
+ %define NAME(name) _ %+ NAME_OVERLOAD(name)
+ %endif
+ %ifdef RT_OS_WINDOWS
+ %define NAME(name) _ %+ NAME_OVERLOAD(name)
+ %endif
%endif
- %ifdef RT_OS_WINDOWS
+ %ifdef RT_OS_DARWIN
%define NAME(name) _ %+ NAME_OVERLOAD(name)
%endif
%endif
-%ifdef RT_OS_DARWIN
- %define NAME(name) _ %+ NAME_OVERLOAD(name)
-%endif
%ifndef NAME
%define NAME(name) NAME_OVERLOAD(name)
%endif
@@ -112,9 +119,9 @@
;;
; Mangles the given C name so it will _import_ the right symbol.
%ifdef ASM_FORMAT_PE
-%define IMPNAME(name) __imp_ %+ NAME(name)
+ %define IMPNAME(name) __imp_ %+ NAME(name)
%else
-%define IMPNAME(name) NAME(name)
+ %define IMPNAME(name) NAME(name)
%endif
;;
@@ -130,6 +137,17 @@
%endif
;;
+; Declares an imported object for use with IMP2.
+; @note May change the current section!
+%macro EXTERN_IMP2 1
+ extern IMPNAME(%1)
+ BEGINDATA
+ %ifdef ASM_FORMAT_MACHO
+ g_Imp2_ %+ %1: RTCCPTR_DEF IMPNAME(%1)
+ %endif
+%endmacro
+
+;;
; Gets the pointer to an imported object, version 2.
%ifdef ASM_FORMAT_PE
%ifdef RT_ARCH_AMD64
@@ -137,12 +155,19 @@
%else
%define IMP2(name) dword [IMPNAME(name)]
%endif
-%else
- %ifdef RT_ARCH_AMD64
- %define IMP2(name) IMPNAME(name) wrt rip
- %else
- %define IMP2(name) IMPNAME(name)
+%elifdef ASM_FORMAT_ELF
+ %ifdef PIC
+ %ifdef RT_ARCH_AMD64
+ %define IMP2(name) qword [rel IMPNAME(name) wrt ..got]
+ %else
+ %define IMP2(name) IMPNAME(name) wrt ..plt
+ %endif
%endif
+%elifdef ASM_FORMAT_MACHO
+ %define IMP2(name) RTCCPTR_PRE [g_Imp2_ %+ name xWrtRIP]
+%endif
+%ifndef IMP2
+ %define IMP2(name) IMPNAME(name)
%endif
@@ -276,8 +301,8 @@ size NAME(%1 %+ _EndProc) 0
%ifdef ASM_FORMAT_MACHO
%ifdef __YASM__
- [section .text]
- [section .data]
+ section .text
+ section .data
%endif
%endif
@@ -290,7 +315,7 @@ size NAME(%1 %+ _EndProc) 0
%endmacro
%else
%macro BEGINCODE 0
-[section .text]
+ section .text
%endmacro
%endif
@@ -307,9 +332,9 @@ size NAME(%1 %+ _EndProc) 0
%else
%macro BEGINCONST 0
%ifdef ASM_FORMAT_MACHO ;; @todo check the other guys too.
- [section .rodata]
+ section .rodata
%else
- [section .text]
+ section .text
%endif
%endmacro
%endif
@@ -322,7 +347,7 @@ size NAME(%1 %+ _EndProc) 0
%endmacro
%else
%macro BEGINDATA 0
-[section .data]
+ section .data
%endmacro
%endif
@@ -334,7 +359,7 @@ size NAME(%1 %+ _EndProc) 0
%endmacro
%else
%macro BEGINBSS 0
-[section .bss]
+ section .bss
%endmacro
%endif
@@ -717,7 +742,7 @@ BEGINPROC RT_NOCRT(%1)
-;; @def xS
+;; @def xCB
; The stack unit size / The register unit size.
;; @def xSP
@@ -748,7 +773,7 @@ BEGINPROC RT_NOCRT(%1)
; 'wrt rip' for AMD64 targets, nothing for x86 ones.
%ifdef RT_ARCH_AMD64
- %define xS 8
+ %define xCB 8
%define xSP rsp
%define xBP rbp
%define xAX rax
@@ -759,7 +784,7 @@ BEGINPROC RT_NOCRT(%1)
%define xSI rsi
%define xWrtRIP wrt rip
%else
- %define xS 4
+ %define xCB 4
%define xSP esp
%define xBP ebp
%define xAX eax
@@ -771,4 +796,37 @@ BEGINPROC RT_NOCRT(%1)
%define xWrtRIP
%endif
+
+;
+; Some simple compile time assertions.
+;
+; Note! Requires new kBuild to work.
+;
+
+;;
+; Structure size assertion macro.
+%define AssertCompileSize(a_Type, a_Size) AssertCompileSizeML a_Type, a_Size
+%macro AssertCompileSizeML 2,
+ %ifndef KBUILD_GENERATING_MAKEFILE_DEPENDENCIES
+ %assign AssertVar_cbActual %1 %+ _size
+ %assign AssertVar_cbExpected %2
+ %if AssertVar_cbActual != AssertVar_cbExpected
+ %error %1 is AssertVar_cbActual bytes instead of AssertVar_cbExpected
+ %endif
+ %endif
+%endmacro
+
+;;
+; Structure memember offset assertion macro.
+%define AssertCompileMemberOffset(a_Type, a_Member, a_off) AssertCompileMemberOffsetML a_Type, a_Member, a_off
+%macro AssertCompileMemberOffsetML 3,
+ %ifndef KBUILD_GENERATING_MAKEFILE_DEPENDENCIES
+ %assign AssertVar_offActual %1 %+ . %+ %2
+ %assign AssertVar_offExpected %3
+ %if AssertVar_offActual != AssertVar_offExpected
+ %error %1 %+ . %+ %2 is at AssertVar_offActual instead of AssertVar_offExpected
+ %endif
+ %endif
+%endmacro
+
%endif
diff --git a/include/iprt/assert.h b/include/iprt/assert.h
index ec1631d1..8b9fba04 100644
--- a/include/iprt/assert.h
+++ b/include/iprt/assert.h
@@ -297,6 +297,8 @@ RT_C_DECLS_END
*/
#ifdef __GNUC__
# define AssertCompileNS(expr) extern int RTASSERTVAR[1] __attribute__((unused)), RTASSERTVAR[(expr) ? 1 : 0] __attribute__((unused))
+#elif defined(__IBMC__) || defined(__IBMCPP__)
+# define AssertCompileNS(expr) extern int RTASSERTVAR[(expr) ? 1 : 0]
#else
# define AssertCompileNS(expr) typedef int RTASSERTTYPE[(expr) ? 1 : 0]
#endif
@@ -312,6 +314,23 @@ RT_C_DECLS_END
# define AssertCompile(expr) AssertCompileNS(expr)
#endif
+/** @def RTASSERT_OFFSET_OF()
+ * A offsetof() macro suitable for compile time assertions.
+ * Both GCC v4 and VisualAge for C++ v3.08 has trouble using RT_OFFSETOF.
+ */
+#if defined(__GNUC__)
+# if __GNUC__ >= 4
+# define RTASSERT_OFFSET_OF(a_Type, a_Member) __builtin_offsetof(a_Type, a_Member)
+# else
+# define RTASSERT_OFFSET_OF(a_Type, a_Member) RT_OFFSETOF(a_Type, a_Member)
+# endif
+#elif (defined(__IBMC__) || defined(__IBMCPP__)) && defined(RT_OS_OS2)
+# define RTASSERT_OFFSET_OF(a_Type, a_Member) __offsetof(a_Type, a_Member)
+#else
+# define RTASSERT_OFFSET_OF(a_Type, a_Member) RT_OFFSETOF(a_Type, a_Member)
+#endif
+
+
/** @def AssertCompileSize
* Asserts a size at compile.
* @param type The type.
@@ -352,18 +371,8 @@ RT_C_DECLS_END
* @param member The member.
* @param align The member offset alignment to assert.
*/
-#if defined(__GNUC__)
-# if __GNUC__ >= 4
-# define AssertCompileMemberAlignment(type, member, align) \
- AssertCompile(!(__builtin_offsetof(type, member) & ((align) - 1)))
-# else
-# define AssertCompileMemberAlignment(type, member, align) \
- AssertCompile(!(RT_OFFSETOF(type, member) & ((align) - 1)))
-# endif
-#else
-# define AssertCompileMemberAlignment(type, member, align) \
- AssertCompile(!(RT_OFFSETOF(type, member) & ((align) - 1)))
-#endif
+#define AssertCompileMemberAlignment(type, member, align) \
+ AssertCompile(!(RTASSERT_OFFSET_OF(type, member) & ((align) - 1)))
/** @def AssertCompileMemberOffset
* Asserts an offset of a structure member at compile.
@@ -371,18 +380,8 @@ RT_C_DECLS_END
* @param member The member.
* @param off The expected offset.
*/
-#if defined(__GNUC__)
-# if __GNUC__ >= 4
-# define AssertCompileMemberOffset(type, member, off) \
- AssertCompile(__builtin_offsetof(type, member) == (off))
-# else
-# define AssertCompileMemberOffset(type, member, off) \
- AssertCompile(RT_OFFSETOF(type, member) == (off))
-# endif
-#else
-# define AssertCompileMemberOffset(type, member, off) \
- AssertCompile(RT_OFFSETOF(type, member) == (off))
-#endif
+#define AssertCompileMemberOffset(type, member, off) \
+ AssertCompile(RTASSERT_OFFSET_OF(type, member) == (off))
/** @def AssertCompile2MemberOffsets
* Asserts that two (sub-structure) members in union have the same offset.
@@ -390,18 +389,8 @@ RT_C_DECLS_END
* @param member1 The first member.
* @param member2 The second member.
*/
-#if defined(__GNUC__)
-# if __GNUC__ >= 4
-# define AssertCompile2MemberOffsets(type, member1, member2) \
- AssertCompile(__builtin_offsetof(type, member1) == __builtin_offsetof(type, member2))
-# else
-# define AssertCompile2MemberOffsets(type, member1, member2) \
- AssertCompile(RT_OFFSETOF(type, member1) == RT_OFFSETOF(type, member2))
-# endif
-#else
-# define AssertCompile2MemberOffsets(type, member1, member2) \
- AssertCompile(RT_OFFSETOF(type, member1) == RT_OFFSETOF(type, member2))
-#endif
+#define AssertCompile2MemberOffsets(type, member1, member2) \
+ AssertCompile(RTASSERT_OFFSET_OF(type, member1) == RTASSERT_OFFSET_OF(type, member2))
/** @def AssertCompileAdjacentMembers
* Asserts that two structure members are adjacent.
@@ -409,18 +398,8 @@ RT_C_DECLS_END
* @param member1 The first member.
* @param member2 The second member.
*/
-#if defined(__GNUC__)
-# if __GNUC__ >= 4
-# define AssertCompileAdjacentMembers(type, member1, member2) \
- AssertCompile(__builtin_offsetof(type, member1) + RT_SIZEOFMEMB(type, member1) == __builtin_offsetof(type, member2))
-# else
-# define AssertCompileAdjacentMembers(type, member1, member2) \
- AssertCompile(RT_OFFSETOF(type, member1) + RT_SIZEOFMEMB(type, member1) == RT_OFFSETOF(type, member2))
-# endif
-#else
-# define AssertCompileAdjacentMembers(type, member1, member2) \
- AssertCompile(RT_OFFSETOF(type, member1) + RT_SIZEOFMEMB(type, member1) == RT_OFFSETOF(type, member2))
-#endif
+#define AssertCompileAdjacentMembers(type, member1, member2) \
+ AssertCompile(RTASSERT_OFFSET_OF(type, member1) + RT_SIZEOFMEMB(type, member1) == RTASSERT_OFFSET_OF(type, member2))
/** @def AssertCompileMembersAtSameOffset
* Asserts that members of two different structures are at the same offset.
@@ -429,18 +408,8 @@ RT_C_DECLS_END
* @param type2 The second type.
* @param member2 The second member.
*/
-#if defined(__GNUC__)
-# if __GNUC__ >= 4
-# define AssertCompileMembersAtSameOffset(type1, member1, type2, member2) \
- AssertCompile(__builtin_offsetof(type1, member1) == __builtin_offsetof(type2, member2))
-# else
-# define AssertCompileMembersAtSameOffset(type1, member1, type2, member2) \
- AssertCompile(RT_OFFSETOF(type1, member1) == RT_OFFSETOF(type2, member2))
-# endif
-#else
-# define AssertCompileMembersAtSameOffset(type1, member1, type2, member2) \
- AssertCompile(RT_OFFSETOF(type1, member1) == RT_OFFSETOF(type2, member2))
-#endif
+#define AssertCompileMembersAtSameOffset(type1, member1, type2, member2) \
+ AssertCompile(RTASSERT_OFFSET_OF(type1, member1) == RTASSERT_OFFSET_OF(type2, member2))
/** @def AssertCompileMembersSameSize
* Asserts that members of two different structures have the same size.
@@ -460,18 +429,9 @@ RT_C_DECLS_END
* @param type2 The second type.
* @param member2 The second member.
*/
-#if defined(__GNUC__)
-# if __GNUC__ >= 4
-# define AssertCompileMembersSameSizeAndOffset(type1, member1, type2, member2) \
- AssertCompile(__builtin_offsetof(type1, member1) == __builtin_offsetof(type2, member2) && RT_SIZEOFMEMB(type1, member1) == RT_SIZEOFMEMB(type2, member2))
-# else
-# define AssertCompileMembersSameSizeAndOffset(type1, member1, type2, member2) \
- AssertCompile(RT_OFFSETOF(type1, member1) == RT_OFFSETOF(type2, member2) && RT_SIZEOFMEMB(type1, member1) == RT_SIZEOFMEMB(type2, member2))
-# endif
-#else
-# define AssertCompileMembersSameSizeAndOffset(type1, member1, type2, member2) \
- AssertCompile(RT_OFFSETOF(type1, member1) == RT_OFFSETOF(type2, member2) && RT_SIZEOFMEMB(type1, member1) == RT_SIZEOFMEMB(type2, member2))
-#endif
+#define AssertCompileMembersSameSizeAndOffset(type1, member1, type2, member2) \
+ AssertCompile( RTASSERT_OFFSET_OF(type1, member1) == RTASSERT_OFFSET_OF(type2, member2) \
+ && RT_SIZEOFMEMB(type1, member1) == RT_SIZEOFMEMB(type2, member2))
/** @} */
@@ -504,7 +464,7 @@ RT_C_DECLS_END
* @remarks This macro does not depend on RT_STRICT.
*/
#if defined(IN_RING0) \
- && (defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS))
+ && (defined(RT_OS_DARWIN) || defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS))
# define RTAssertDoPanic() RTR0AssertPanicSystem()
#else
# define RTAssertDoPanic() RTAssertDebugBreak()
@@ -1511,6 +1471,23 @@ RT_C_DECLS_END
RTAssertPanic(); \
} while (0)
+/** @def AssertLogRelMsgFailedStmt
+ * An assertion failed, execute @a stmt.
+ *
+ * Strict builds will hit a breakpoint, non-strict will only do LogRel. The
+ * statement will be executed in regardless of build type.
+ *
+ * @param a printf argument list (in parenthesis).
+ * @param stmt Statement to execute after raising/logging the assertion.
+ */
+#define AssertLogRelMsgFailedStmt(a, stmt) \
+ do { \
+ RTAssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
+ RTAssertLogRelMsg2(a); \
+ RTAssertPanic(); \
+ stmt; \
+ } while (0)
+
/** @def AssertLogRelMsgFailedReturn
* An assertion failed, return \a rc.
* Strict builds will hit a breakpoint, non-strict will only do LogRel.
diff --git a/include/iprt/avl.h b/include/iprt/avl.h
index 9c1b99df..2347b80e 100644
--- a/include/iprt/avl.h
+++ b/include/iprt/avl.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1999-2003 knut st. osmundsen <bird-src-spam@anduin.net>
+ * Copyright (C) 1999-2012 knut st. osmundsen <bird-src-spam@anduin.net>
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -62,7 +62,8 @@ typedef PAVLPVNODECORE AVLPVTREE;
/** Pointer to a tree with void pointer keys. */
typedef PPAVLPVNODECORE PAVLPVTREE;
-/** Callback function for AVLPVDoWithAll(). */
+/** Callback function for AVLPVDoWithAll().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLPVCALLBACK(PAVLPVNODECORE, void *);
/** Pointer to callback function for AVLPVDoWithAll(). */
typedef AVLPVCALLBACK *PAVLPVCALLBACK;
@@ -102,7 +103,8 @@ typedef struct _AVLULNodeCore
} AVLULNODECORE, *PAVLULNODECORE, **PPAVLULNODECORE;
-/** Callback function for AVLULDoWithAll(). */
+/** Callback function for AVLULDoWithAll().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLULCALLBACK(PAVLULNODECORE, void*);
/** Pointer to callback function for AVLULDoWithAll(). */
typedef AVLULCALLBACK *PAVLULCALLBACK;
@@ -149,7 +151,8 @@ typedef PAVLRPVNODECORE AVLRPVTREE;
/** Pointer to a tree with void pointer keys. */
typedef PPAVLRPVNODECORE PAVLRPVTREE;
-/** Callback function for AVLPVDoWithAll(). */
+/** Callback function for AVLPVDoWithAll().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLRPVCALLBACK(PAVLRPVNODECORE, void *);
/** Pointer to callback function for AVLPVDoWithAll(). */
typedef AVLRPVCALLBACK *PAVLRPVCALLBACK;
@@ -192,7 +195,8 @@ typedef PAVLU32NODECORE AVLU32TREE;
/** Pointer to a tree with void pointer keys. */
typedef PPAVLU32NODECORE PAVLU32TREE;
-/** Callback function for AVLU32DoWithAll() & AVLU32Destroy(). */
+/** Callback function for AVLU32DoWithAll() & AVLU32Destroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLU32CALLBACK(PAVLU32NODECORE, void*);
/** Pointer to callback function for AVLU32DoWithAll() & AVLU32Destroy(). */
typedef AVLU32CALLBACK *PAVLU32CALLBACK;
@@ -242,7 +246,8 @@ typedef AVLOU32TREE *PAVLOU32TREE;
* In this case it's a pointer to a relative offset. */
typedef AVLOU32TREE *PPAVLOU32NODECORE;
-/** Callback function for RTAvloU32DoWithAll(). */
+/** Callback function for RTAvloU32DoWithAll().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLOU32CALLBACK(PAVLOU32NODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvloU32DoWithAll(). */
typedef AVLOU32CALLBACK *PAVLOU32CALLBACK;
@@ -275,7 +280,8 @@ typedef struct _AVLLU32NodeCore
struct _AVLLU32NodeCore *pList; /**< Pointer to next node with the same key. */
} AVLLU32NODECORE, *PAVLLU32NODECORE, **PPAVLLU32NODECORE;
-/** Callback function for RTAvllU32DoWithAll() & RTAvllU32Destroy(). */
+/** Callback function for RTAvllU32DoWithAll() & RTAvllU32Destroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLLU32CALLBACK(PAVLLU32NODECORE, void*);
/** Pointer to callback function for RTAvllU32DoWithAll() & RTAvllU32Destroy(). */
typedef AVLLU32CALLBACK *PAVLLU32CALLBACK;
@@ -323,7 +329,8 @@ typedef PAVLRU64NODECORE AVLRU64TREE;
/** Pointer to a tree with void pointer keys. */
typedef PPAVLRU64NODECORE PAVLRU64TREE;
-/** Callback function for AVLRU64DoWithAll(). */
+/** Callback function for AVLRU64DoWithAll().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLRU64CALLBACK(PAVLRU64NODECORE, void *);
/** Pointer to callback function for AVLU64DoWithAll(). */
typedef AVLRU64CALLBACK *PAVLRU64CALLBACK;
@@ -380,7 +387,8 @@ typedef AVLOGCPHYSTREE *PAVLOGCPHYSTREE;
* In this case it's a pointer to a relative offset. */
typedef AVLOGCPHYSTREE *PPAVLOGCPHYSNODECORE;
-/** Callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy(). */
+/** Callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLOGCPHYSCALLBACK(PAVLOGCPHYSNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvloGCPhysDoWithAll() and RTAvloGCPhysDestroy(). */
typedef AVLOGCPHYSCALLBACK *PAVLOGCPHYSCALLBACK;
@@ -433,7 +441,8 @@ typedef AVLROGCPHYSTREE *PAVLROGCPHYSTREE;
* In this case it's a pointer to a relative offset. */
typedef AVLROGCPHYSTREE *PPAVLROGCPHYSNODECORE;
-/** Callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy(). */
+/** Callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLROGCPHYSCALLBACK(PAVLROGCPHYSNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlroGCPhysDoWithAll() and RTAvlroGCPhysDestroy(). */
typedef AVLROGCPHYSCALLBACK *PAVLROGCPHYSCALLBACK;
@@ -477,7 +486,8 @@ typedef PAVLGCPTRNODECORE AVLGCPTRTREE;
/** Pointer to a tree of RTGCPTR keys. */
typedef PPAVLGCPTRNODECORE PAVLGCPTRTREE;
-/** Callback function for RTAvlGCPtrDoWithAll(). */
+/** Callback function for RTAvlGCPtrDoWithAll().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLGCPTRCALLBACK(PAVLGCPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlGCPtrDoWithAll(). */
typedef AVLGCPTRCALLBACK *PAVLGCPTRCALLBACK;
@@ -527,7 +537,8 @@ typedef AVLOGCPTRTREE *PAVLOGCPTRTREE;
* In this case it's a pointer to a relative offset. */
typedef AVLOGCPTRTREE *PPAVLOGCPTRNODECORE;
-/** Callback function for RTAvloGCPtrDoWithAll(). */
+/** Callback function for RTAvloGCPtrDoWithAll().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLOGCPTRCALLBACK(PAVLOGCPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvloGCPtrDoWithAll(). */
typedef AVLOGCPTRCALLBACK *PAVLOGCPTRCALLBACK;
@@ -573,7 +584,8 @@ typedef AVLRGCPTRTREE *PAVLRGCPTRTREE;
* In this case it's a pointer to a relative offset. */
typedef AVLRGCPTRTREE *PPAVLRGCPTRNODECORE;
-/** Callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
+/** Callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLRGCPTRCALLBACK(PAVLRGCPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
typedef AVLRGCPTRCALLBACK *PAVLRGCPTRCALLBACK;
@@ -629,7 +641,8 @@ typedef AVLROGCPTRTREE *PAVLROGCPTRTREE;
* In this case it's a pointer to a relative offset. */
typedef AVLROGCPTRTREE *PPAVLROGCPTRNODECORE;
-/** Callback function for RTAvlroGCPtrDoWithAll() and RTAvlroGCPtrDestroy(). */
+/** Callback function for RTAvlroGCPtrDoWithAll() and RTAvlroGCPtrDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLROGCPTRCALLBACK(PAVLROGCPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlroGCPtrDoWithAll() and RTAvlroGCPtrDestroy(). */
typedef AVLROGCPTRCALLBACK *PAVLROGCPTRCALLBACK;
@@ -686,7 +699,8 @@ typedef AVLROOGCPTRTREE *PAVLROOGCPTRTREE;
* In this case it's a pointer to a relative offset. */
typedef AVLROOGCPTRTREE *PPAVLROOGCPTRNODECORE;
-/** Callback function for RTAvlrooGCPtrDoWithAll() and RTAvlrooGCPtrDestroy(). */
+/** Callback function for RTAvlrooGCPtrDoWithAll() and RTAvlrooGCPtrDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLROOGCPTRCALLBACK(PAVLROOGCPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlrooGCPtrDoWithAll() and RTAvlrooGCPtrDestroy(). */
typedef AVLROOGCPTRCALLBACK *PAVLROOGCPTRCALLBACK;
@@ -737,7 +751,8 @@ typedef AVLUINTPTRTREE *PAVLUINTPTRTREE;
* In this case it's a pointer to a pointer. */
typedef AVLUINTPTRTREE *PPAVLUINTPTRNODECORE;
-/** Callback function for RTAvlUIntPtrDoWithAll() and RTAvlUIntPtrDestroy(). */
+/** Callback function for RTAvlUIntPtrDoWithAll() and RTAvlUIntPtrDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLUINTPTRCALLBACK(PAVLUINTPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlUIntPtrDoWithAll() and RTAvlUIntPtrDestroy(). */
typedef AVLUINTPTRCALLBACK *PAVLUINTPTRCALLBACK;
@@ -787,7 +802,8 @@ typedef AVLRUINTPTRTREE *PAVLRUINTPTRTREE;
* In this case it's a pointer to a pointer. */
typedef AVLRUINTPTRTREE *PPAVLRUINTPTRNODECORE;
-/** Callback function for RTAvlrUIntPtrDoWithAll() and RTAvlrUIntPtrDestroy(). */
+/** Callback function for RTAvlrUIntPtrDoWithAll() and RTAvlrUIntPtrDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLRUINTPTRCALLBACK(PAVLRUINTPTRNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlrUIntPtrDoWithAll() and RTAvlrUIntPtrDestroy(). */
typedef AVLRUINTPTRCALLBACK *PAVLRUINTPTRCALLBACK;
@@ -843,7 +859,8 @@ typedef AVLOHCPHYSTREE *PAVLOHCPHYSTREE;
* In this case it's a pointer to a relative offset. */
typedef AVLOHCPHYSTREE *PPAVLOHCPHYSNODECORE;
-/** Callback function for RTAvloHCPhysDoWithAll() and RTAvloHCPhysDestroy(). */
+/** Callback function for RTAvloHCPhysDoWithAll() and RTAvloHCPhysDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLOHCPHYSCALLBACK(PAVLOHCPHYSNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvloHCPhysDoWithAll() and RTAvloHCPhysDestroy(). */
typedef AVLOHCPHYSCALLBACK *PAVLOHCPHYSCALLBACK;
@@ -893,7 +910,8 @@ typedef AVLOIOPORTTREE *PAVLOIOPORTTREE;
* In this case it's a pointer to a relative offset. */
typedef AVLOIOPORTTREE *PPAVLOIOPORTNODECORE;
-/** Callback function for RTAvloIOPortDoWithAll() and RTAvloIOPortDestroy(). */
+/** Callback function for RTAvloIOPortDoWithAll() and RTAvloIOPortDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLOIOPORTCALLBACK(PAVLOIOPORTNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvloIOPortDoWithAll() and RTAvloIOPortDestroy(). */
typedef AVLOIOPORTCALLBACK *PAVLOIOPORTCALLBACK;
@@ -944,7 +962,8 @@ typedef AVLROIOPORTTREE *PAVLROIOPORTTREE;
* In this case it's a pointer to a relative offset. */
typedef AVLROIOPORTTREE *PPAVLROIOPORTNODECORE;
-/** Callback function for RTAvlroIOPortDoWithAll() and RTAvlroIOPortDestroy(). */
+/** Callback function for RTAvlroIOPortDoWithAll() and RTAvlroIOPortDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLROIOPORTCALLBACK(PAVLROIOPORTNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlroIOPortDoWithAll() and RTAvlroIOPortDestroy(). */
typedef AVLROIOPORTCALLBACK *PAVLROIOPORTCALLBACK;
@@ -993,7 +1012,8 @@ typedef AVLHCPHYSTREE *PAVLHCPHYSTREE;
* In this case it's a pointer to a relative offset. */
typedef AVLHCPHYSTREE *PPAVLHCPHYSNODECORE;
-/** Callback function for RTAvlHCPhysDoWithAll() and RTAvlHCPhysDestroy(). */
+/** Callback function for RTAvlHCPhysDoWithAll() and RTAvlHCPhysDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLHCPHYSCALLBACK(PAVLHCPHYSNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlHCPhysDoWithAll() and RTAvlHCPhysDestroy(). */
typedef AVLHCPHYSCALLBACK *PAVLHCPHYSCALLBACK;
@@ -1041,7 +1061,8 @@ typedef AVLGCPHYSTREE *PAVLGCPHYSTREE;
* In this case it's a pointer to a relative offset. */
typedef AVLGCPHYSTREE *PPAVLGCPHYSNODECORE;
-/** Callback function for RTAvlGCPhysDoWithAll() and RTAvlGCPhysDestroy(). */
+/** Callback function for RTAvlGCPhysDoWithAll() and RTAvlGCPhysDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLGCPHYSCALLBACK(PAVLGCPHYSNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlGCPhysDoWithAll() and RTAvlGCPhysDestroy(). */
typedef AVLGCPHYSCALLBACK *PAVLGCPHYSCALLBACK;
@@ -1087,7 +1108,8 @@ typedef AVLRFOFFTREE *PAVLRFOFFTREE;
* In this case it's a pointer to a relative offset. */
typedef AVLRFOFFTREE *PPAVLRFOFFNODECORE;
-/** Callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
+/** Callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy().
+ * @returns IPRT status codes. */
typedef DECLCALLBACK(int) AVLRFOFFCALLBACK(PAVLRFOFFNODECORE pNode, void *pvUser);
/** Pointer to callback function for RTAvlrGCPtrDoWithAll() and RTAvlrGCPtrDestroy(). */
typedef AVLRFOFFCALLBACK *PAVLRFOFFCALLBACK;
diff --git a/include/iprt/base64.h b/include/iprt/base64.h
index b52f48e1..dfbbc134 100644
--- a/include/iprt/base64.h
+++ b/include/iprt/base64.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-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;
diff --git a/include/iprt/buildconfig.h b/include/iprt/buildconfig.h
index 9e4a9c57..8853fb80 100644
--- a/include/iprt/buildconfig.h
+++ b/include/iprt/buildconfig.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-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;
diff --git a/include/iprt/cdefs.h b/include/iprt/cdefs.h
index db52defa..744fd48b 100644
--- a/include/iprt/cdefs.h
+++ b/include/iprt/cdefs.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -31,16 +31,6 @@
* @{
*/
-/*
- * Include sys/cdefs.h if present, if not define the stuff we need.
- */
-#ifdef HAVE_SYS_CDEFS_H
-# if defined(RT_ARCH_LINUX) && defined(__KERNEL__)
-# error "oops"
-# endif
-# include <sys/cdefs.h>
-#else
-
/** @def RT_C_DECLS_BEGIN
* Used to start a block of function declarations which are shared
* between C and C++ program.
@@ -51,14 +41,12 @@
* between C and C++ program.
*/
-# if defined(__cplusplus)
-# define RT_C_DECLS_BEGIN extern "C" {
-# define RT_C_DECLS_END }
-# else
-# define RT_C_DECLS_BEGIN
-# define RT_C_DECLS_END
-# endif
-
+#if defined(__cplusplus)
+# define RT_C_DECLS_BEGIN extern "C" {
+# define RT_C_DECLS_END }
+#else
+# define RT_C_DECLS_BEGIN
+# define RT_C_DECLS_END
#endif
@@ -283,6 +271,321 @@
#endif
+
+/** @name RT_OPSYS_XXX - Operative System Identifiers.
+ * These are the value that the RT_OPSYS \#define can take. @{
+ */
+/** Unknown OS. */
+#define RT_OPSYS_UNKNOWN 0
+/** OS Agnostic. */
+#define RT_OPSYS_AGNOSTIC 1
+/** Darwin - aka Mac OS X. */
+#define RT_OPSYS_DARWIN 2
+/** DragonFly BSD. */
+#define RT_OPSYS_DRAGONFLY 3
+/** DOS. */
+#define RT_OPSYS_DOS 4
+/** FreeBSD. */
+#define RT_OPSYS_FREEBSD 5
+/** Haiku. */
+#define RT_OPSYS_HAIKU 6
+/** Linux. */
+#define RT_OPSYS_LINUX 7
+/** L4. */
+#define RT_OPSYS_L4 8
+/** Minix. */
+#define RT_OPSYS_MINIX 9
+/** NetBSD. */
+#define RT_OPSYS_NETBSD 11
+/** Netware. */
+#define RT_OPSYS_NETWARE 12
+/** NT (native). */
+#define RT_OPSYS_NT 13
+/** OpenBSD. */
+#define RT_OPSYS_OPENBSD 14
+/** OS/2. */
+#define RT_OPSYS_OS2 15
+/** Plan 9. */
+#define RT_OPSYS_PLAN9 16
+/** QNX. */
+#define RT_OPSYS_QNX 17
+/** Solaris. */
+#define RT_OPSYS_SOLARIS 18
+/** UEFI. */
+#define RT_OPSYS_UEFI 19
+/** Windows. */
+#define RT_OPSYS_WINDOWS 20
+/** The max RT_OPSYS_XXX value (exclusive). */
+#define RT_OPSYS_MAX 21
+/** @} */
+
+/** @def RT_OPSYS
+ * Indicates which OS we're targetting. It's a \#define with is
+ * assigned one of the RT_OPSYS_XXX defines above.
+ *
+ * So to test if we're on FreeBSD do the following:
+ * @code
+ * #if RT_OPSYS == RT_OPSYS_FREEBSD
+ * some_funky_freebsd_specific_stuff();
+ * #endif
+ * @endcode
+ */
+
+/*
+ * Set RT_OPSYS_XXX according to RT_OS_XXX.
+ *
+ * Search: #define RT_OPSYS_([A-Z0-9]+) .*
+ * Replace: # elif defined(RT_OS_\1)\n# define RT_OPSYS RT_OPSYS_\1
+ */
+#ifndef RT_OPSYS
+# if defined(RT_OS_UNKNOWN)
+# define RT_OPSYS RT_OPSYS_UNKNOWN
+# elif defined(RT_OS_AGNOSTIC)
+# define RT_OPSYS RT_OPSYS_AGNOSTIC
+# elif defined(RT_OS_DARWIN)
+# define RT_OPSYS RT_OPSYS_DARWIN
+# elif defined(RT_OS_DRAGONFLY)
+# define RT_OPSYS RT_OPSYS_DRAGONFLY
+# elif defined(RT_OS_DOS)
+# define RT_OPSYS RT_OPSYS_DOS
+# elif defined(RT_OS_FREEBSD)
+# define RT_OPSYS RT_OPSYS_FREEBSD
+# elif defined(RT_OS_HAIKU)
+# define RT_OPSYS RT_OPSYS_HAIKU
+# elif defined(RT_OS_LINUX)
+# define RT_OPSYS RT_OPSYS_LINUX
+# elif defined(RT_OS_L4)
+# define RT_OPSYS RT_OPSYS_L4
+# elif defined(RT_OS_MINIX)
+# define RT_OPSYS RT_OPSYS_MINIX
+# elif defined(RT_OS_NETBSD)
+# define RT_OPSYS RT_OPSYS_NETBSD
+# elif defined(RT_OS_NETWARE)
+# define RT_OPSYS RT_OPSYS_NETWARE
+# elif defined(RT_OS_NT)
+# define RT_OPSYS RT_OPSYS_NT
+# elif defined(RT_OS_OPENBSD)
+# define RT_OPSYS RT_OPSYS_OPENBSD
+# elif defined(RT_OS_OS2)
+# define RT_OPSYS RT_OPSYS_OS2
+# elif defined(RT_OS_PLAN9)
+# define RT_OPSYS RT_OPSYS_PLAN9
+# elif defined(RT_OS_QNX)
+# define RT_OPSYS RT_OPSYS_QNX
+# elif defined(RT_OS_SOLARIS)
+# define RT_OPSYS RT_OPSYS_SOLARIS
+# elif defined(RT_OS_UEFI)
+# define RT_OPSYS RT_OPSYS_UEFI
+# elif defined(RT_OS_WINDOWS)
+# define RT_OPSYS RT_OPSYS_WINDOWS
+# endif
+#endif
+
+/*
+ * Guess RT_OPSYS based on compiler predefined macros.
+ */
+#ifndef RT_OPSYS
+# if defined(__APPLE__)
+# define RT_OPSYS RT_OPSYS_DARWIN
+# elif defined(__DragonFly__)
+# define RT_OPSYS RT_OPSYS_DRAGONFLY
+# elif defined(__FreeBSD__) /*??*/
+# define RT_OPSYS RT_OPSYS_FREEBSD
+# elif defined(__gnu_linux__)
+# define RT_OPSYS RT_OPSYS_LINUX
+# elif defined(__NetBSD__) /*??*/
+# define RT_OPSYS RT_OPSYS_NETBSD
+# elif defined(__OpenBSD__) /*??*/
+# define RT_OPSYS RT_OPSYS_OPENBSD
+# elif defined(__OS2__)
+# define RT_OPSYS RT_OPSYS_OS2
+# elif defined(__sun__) || defined(__SunOS__) || defined(__sun) || defined(__SunOS)
+# define RT_OPSYS RT_OPSYS_SOLARIS
+# elif defined(_WIN32) || defined(_WIN64)
+# define RT_OPSYS RT_OPSYS_WINDOWS
+# else
+# error "Port Me"
+# endif
+#endif
+
+#if RT_OPSYS < RT_OPSYS_UNKNOWN || RT_OPSYS >= RT_OPSYS_MAX
+# error "Invalid RT_OPSYS value."
+#endif
+
+/*
+ * Do some consistency checks.
+ *
+ * Search: #define RT_OPSYS_([A-Z0-9]+) .*
+ * Replace: #if defined(RT_OS_\1) && RT_OPSYS != RT_OPSYS_\1\n# error RT_OPSYS vs RT_OS_\1\n#endif
+ */
+#if defined(RT_OS_UNKNOWN) && RT_OPSYS != RT_OPSYS_UNKNOWN
+# error RT_OPSYS vs RT_OS_UNKNOWN
+#endif
+#if defined(RT_OS_AGNOSTIC) && RT_OPSYS != RT_OPSYS_AGNOSTIC
+# error RT_OPSYS vs RT_OS_AGNOSTIC
+#endif
+#if defined(RT_OS_DARWIN) && RT_OPSYS != RT_OPSYS_DARWIN
+# error RT_OPSYS vs RT_OS_DARWIN
+#endif
+#if defined(RT_OS_DRAGONFLY) && RT_OPSYS != RT_OPSYS_DRAGONFLY
+# error RT_OPSYS vs RT_OS_DRAGONFLY
+#endif
+#if defined(RT_OS_DOS) && RT_OPSYS != RT_OPSYS_DOS
+# error RT_OPSYS vs RT_OS_DOS
+#endif
+#if defined(RT_OS_FREEBSD) && RT_OPSYS != RT_OPSYS_FREEBSD
+# error RT_OPSYS vs RT_OS_FREEBSD
+#endif
+#if defined(RT_OS_HAIKU) && RT_OPSYS != RT_OPSYS_HAIKU
+# error RT_OPSYS vs RT_OS_HAIKU
+#endif
+#if defined(RT_OS_LINUX) && RT_OPSYS != RT_OPSYS_LINUX
+# error RT_OPSYS vs RT_OS_LINUX
+#endif
+#if defined(RT_OS_L4) && RT_OPSYS != RT_OPSYS_L4
+# error RT_OPSYS vs RT_OS_L4
+#endif
+#if defined(RT_OS_MINIX) && RT_OPSYS != RT_OPSYS_MINIX
+# error RT_OPSYS vs RT_OS_MINIX
+#endif
+#if defined(RT_OS_NETBSD) && RT_OPSYS != RT_OPSYS_NETBSD
+# error RT_OPSYS vs RT_OS_NETBSD
+#endif
+#if defined(RT_OS_NETWARE) && RT_OPSYS != RT_OPSYS_NETWARE
+# error RT_OPSYS vs RT_OS_NETWARE
+#endif
+#if defined(RT_OS_NT) && RT_OPSYS != RT_OPSYS_NT
+# error RT_OPSYS vs RT_OS_NT
+#endif
+#if defined(RT_OS_OPENBSD) && RT_OPSYS != RT_OPSYS_OPENBSD
+# error RT_OPSYS vs RT_OS_OPENBSD
+#endif
+#if defined(RT_OS_OS2) && RT_OPSYS != RT_OPSYS_OS2
+# error RT_OPSYS vs RT_OS_OS2
+#endif
+#if defined(RT_OS_PLAN9) && RT_OPSYS != RT_OPSYS_PLAN9
+# error RT_OPSYS vs RT_OS_PLAN9
+#endif
+#if defined(RT_OS_QNX) && RT_OPSYS != RT_OPSYS_QNX
+# error RT_OPSYS vs RT_OS_QNX
+#endif
+#if defined(RT_OS_SOLARIS) && RT_OPSYS != RT_OPSYS_SOLARIS
+# error RT_OPSYS vs RT_OS_SOLARIS
+#endif
+#if defined(RT_OS_UEFI) && RT_OPSYS != RT_OPSYS_UEFI
+# error RT_OPSYS vs RT_OS_UEFI
+#endif
+#if defined(RT_OS_WINDOWS) && RT_OPSYS != RT_OPSYS_WINDOWS
+# error RT_OPSYS vs RT_OS_WINDOWS
+#endif
+
+/*
+ * Make sure the RT_OS_XXX macro is defined.
+ *
+ * Search: #define RT_OPSYS_([A-Z0-9]+) .*
+ * Replace: #elif RT_OPSYS == RT_OPSYS_\1\n# ifndef RT_OS_\1\n# define RT_OS_\1\n# endif
+ */
+#if RT_OPSYS == RT_OPSYS_UNKNOWN
+# ifndef RT_OS_UNKNOWN
+# define RT_OS_UNKNOWN
+# endif
+#elif RT_OPSYS == RT_OPSYS_AGNOSTIC
+# ifndef RT_OS_AGNOSTIC
+# define RT_OS_AGNOSTIC
+# endif
+#elif RT_OPSYS == RT_OPSYS_DARWIN
+# ifndef RT_OS_DARWIN
+# define RT_OS_DARWIN
+# endif
+#elif RT_OPSYS == RT_OPSYS_DRAGONFLY
+# ifndef RT_OS_DRAGONFLY
+# define RT_OS_DRAGONFLY
+# endif
+#elif RT_OPSYS == RT_OPSYS_DOS
+# ifndef RT_OS_DOS
+# define RT_OS_DOS
+# endif
+#elif RT_OPSYS == RT_OPSYS_FREEBSD
+# ifndef RT_OS_FREEBSD
+# define RT_OS_FREEBSD
+# endif
+#elif RT_OPSYS == RT_OPSYS_HAIKU
+# ifndef RT_OS_HAIKU
+# define RT_OS_HAIKU
+# endif
+#elif RT_OPSYS == RT_OPSYS_LINUX
+# ifndef RT_OS_LINUX
+# define RT_OS_LINUX
+# endif
+#elif RT_OPSYS == RT_OPSYS_L4
+# ifndef RT_OS_L4
+# define RT_OS_L4
+# endif
+#elif RT_OPSYS == RT_OPSYS_MINIX
+# ifndef RT_OS_MINIX
+# define RT_OS_MINIX
+# endif
+#elif RT_OPSYS == RT_OPSYS_NETBSD
+# ifndef RT_OS_NETBSD
+# define RT_OS_NETBSD
+# endif
+#elif RT_OPSYS == RT_OPSYS_NETWARE
+# ifndef RT_OS_NETWARE
+# define RT_OS_NETWARE
+# endif
+#elif RT_OPSYS == RT_OPSYS_NT
+# ifndef RT_OS_NT
+# define RT_OS_NT
+# endif
+#elif RT_OPSYS == RT_OPSYS_OPENBSD
+# ifndef RT_OS_OPENBSD
+# define RT_OS_OPENBSD
+# endif
+#elif RT_OPSYS == RT_OPSYS_OS2
+# ifndef RT_OS_OS2
+# define RT_OS_OS2
+# endif
+#elif RT_OPSYS == RT_OPSYS_PLAN9
+# ifndef RT_OS_PLAN9
+# define RT_OS_PLAN9
+# endif
+#elif RT_OPSYS == RT_OPSYS_QNX
+# ifndef RT_OS_QNX
+# define RT_OS_QNX
+# endif
+#elif RT_OPSYS == RT_OPSYS_SOLARIS
+# ifndef RT_OS_SOLARIS
+# define RT_OS_SOLARIS
+# endif
+#elif RT_OPSYS == RT_OPSYS_UEFI
+# ifndef RT_OS_UEFI
+# define RT_OS_UEFI
+# endif
+#elif RT_OPSYS == RT_OPSYS_WINDOWS
+# ifndef RT_OS_WINDOWS
+# define RT_OS_WINDOWS
+# endif
+#else
+# error "Bad RT_OPSYS value."
+#endif
+
+
+/**
+ * Checks whether the given OpSys uses DOS-style paths or not.
+ *
+ * By DOS-style paths we include drive lettering and UNC paths.
+ *
+ * @returns true / false
+ * @param a_OpSys The RT_OPSYS_XXX value to check, will be reference
+ * multiple times.
+ */
+#define RT_OPSYS_USES_DOS_PATHS(a_OpSys) \
+ ( (a_OpSys) == RT_OPSYS_WINDOWS \
+ || (a_OpSys) == RT_OPSYS_OS2 \
+ || (a_OpSys) == RT_OPSYS_DOS )
+
+
+
/** @def CTXTYPE
* Declare a type differently in GC, R3 and R0.
*
@@ -762,14 +1065,22 @@
* @param type The return type of the function declaration.
* @param name The name of the variable member.
*/
-#define DECLCALLBACKPTR(type, name) type (RTCALL * name)
+#if defined(__IBMC__) || defined(__IBMCPP__)
+# define DECLCALLBACKPTR(type, name) type (* RTCALL name)
+#else
+# define DECLCALLBACKPTR(type, name) type (RTCALL * name)
+#endif
/** @def DECLCALLBACKMEMBER
* How to declare an call back function pointer member.
* @param type The return type of the function declaration.
* @param name The name of the struct/union/class member.
*/
-#define DECLCALLBACKMEMBER(type, name) type (RTCALL * name)
+#if defined(__IBMC__) || defined(__IBMCPP__)
+# define DECLCALLBACKMEMBER(type, name) type (* RTCALL name)
+#else
+# define DECLCALLBACKMEMBER(type, name) type (RTCALL * name)
+#endif
/** @def DECLR3CALLBACKMEMBER
* How to declare an call back function pointer member - R3 Ptr.
@@ -778,7 +1089,7 @@
* @param args The argument list enclosed in parentheses.
*/
#ifdef IN_RING3
-# define DECLR3CALLBACKMEMBER(type, name, args) type (RTCALL * name) args
+# define DECLR3CALLBACKMEMBER(type, name, args) DECLCALLBACKMEMBER(type, name) args
#else
# define DECLR3CALLBACKMEMBER(type, name, args) RTR3PTR name
#endif
@@ -790,7 +1101,7 @@
* @param args The argument list enclosed in parentheses.
*/
#ifdef IN_RC
-# define DECLRCCALLBACKMEMBER(type, name, args) type (RTCALL * name) args
+# define DECLRCCALLBACKMEMBER(type, name, args) DECLCALLBACKMEMBER(type, name) args
#else
# define DECLRCCALLBACKMEMBER(type, name, args) RTRCPTR name
#endif
@@ -802,7 +1113,7 @@
* @param args The argument list enclosed in parentheses.
*/
#ifdef IN_RING0
-# define DECLR0CALLBACKMEMBER(type, name, args) type (RTCALL * name) args
+# define DECLR0CALLBACKMEMBER(type, name, args) DECLCALLBACKMEMBER(type, name) args
#else
# define DECLR0CALLBACKMEMBER(type, name, args) RTR0PTR name
#endif
@@ -1093,6 +1404,14 @@
#define RT_STR_TUPLE(a_szConst) a_szConst, (sizeof(a_szConst) - 1)
+/**
+ * Macro for using in switch statements that turns constants into strings.
+ *
+ * @param a_Const The constant (not string).
+ */
+#define RT_CASE_RET_STR(a_Const) case a_Const: return #a_Const
+
+
/** @def RT_BIT
* Convert a bit number into an integer bitmask (unsigned).
* @param bit The bit number.
@@ -1362,9 +1681,9 @@
/** @def RT_LO_U16
* Gets the low uint16_t of a uint32_t or something equivalent. */
#ifdef __GNUC__
-# define RT_LO_U16(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint64_t)); (uint32_t)(a); })
+# define RT_LO_U16(a) __extension__ ({ AssertCompile(sizeof((a)) == sizeof(uint32_t)); (uint16_t)(a); })
#else
-# define RT_LO_U16(a) ( (uint32_t)(a) )
+# define RT_LO_U16(a) ( (uint16_t)(a) )
#endif
/** @def RT_HI_U16
* Gets the high uint16_t of a uint32_t or something equivalent). */
@@ -2332,10 +2651,17 @@
#endif
/** @def RT_INLINE_ASM_USES_INTRIN
- * Defined as 1 if the compiler have and uses intrin.h. Otherwise it is 0. */
+ * Defined as the major MSC version if the compiler have and uses intrin.h.
+ * Otherwise it is 0. */
#ifdef _MSC_VER
-# if _MSC_VER >= 1400
-# define RT_INLINE_ASM_USES_INTRIN 1
+# if _MSC_VER >= 1700 /* Visual C++ v11.0 / 2012 */
+# define RT_INLINE_ASM_USES_INTRIN 17
+# elif _MSC_VER >= 1600 /* Visual C++ v10.0 / 2010 */
+# define RT_INLINE_ASM_USES_INTRIN 16
+# elif _MSC_VER >= 1500 /* Visual C++ v9.0 / 2008 */
+# define RT_INLINE_ASM_USES_INTRIN 15
+# elif _MSC_VER >= 1400 /* Visual C++ v8.0 / 2005 */
+# define RT_INLINE_ASM_USES_INTRIN 14
# endif
#endif
#ifndef RT_INLINE_ASM_USES_INTRIN
diff --git a/include/iprt/cidr.h b/include/iprt/cidr.h
index 5e054186..8e56453c 100644
--- a/include/iprt/cidr.h
+++ b/include/iprt/cidr.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-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;
@@ -29,6 +29,7 @@
#include <iprt/cdefs.h>
#include <iprt/types.h>
+#include <iprt/net.h>
/** @defgroup grp_rt_cidr RTCidr - Classless Inter-Domain Routing notation
* @ingroup grp_rt
@@ -36,14 +37,6 @@
*/
RT_C_DECLS_BEGIN
-/** An IPv4 address. */
-typedef uint32_t RTIPV4ADDR;
-/** Pointer to an IPv4 address. */
-typedef RTIPV4ADDR *PRTIPV4ADDR;
-/** Pointer to a const IPv4 address. */
-typedef RTIPV4ADDR const *PCRTIPV4ADDR;
-
-
/**
* Parse a string which contains an IP address in CIDR (Classless Inter-Domain Routing) notation.
*
@@ -53,7 +46,7 @@ typedef RTIPV4ADDR const *PCRTIPV4ADDR;
* @param pNetwork The determined IP address / network.
* @param pNetmask The determined netmask.
*/
-RTDECL(int) RTCidrStrToIPv4(const char *pszAddress, PRTIPV4ADDR pNetwork, PRTIPV4ADDR pNetmask);
+RTDECL(int) RTCidrStrToIPv4(const char *pszAddress, PRTNETADDRIPV4 pNetwork, PRTNETADDRIPV4 pNetmask);
RT_C_DECLS_END
/** @} */
diff --git a/include/iprt/circbuf.h b/include/iprt/circbuf.h
index b0c58ffe..99f0d82e 100644
--- a/include/iprt/circbuf.h
+++ b/include/iprt/circbuf.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-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;
diff --git a/include/iprt/cpp/list.h b/include/iprt/cpp/list.h
index 97c1a193..ca8c8f3c 100644
--- a/include/iprt/cpp/list.h
+++ b/include/iprt/cpp/list.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2011 Oracle Corporation
+ * Copyright (C) 2011-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -29,6 +29,7 @@
#include <iprt/cpp/meta.h>
#include <iprt/mem.h>
#include <iprt/string.h> /* for memcpy */
+#include <iprt/assert.h>
#include <new> /* For std::bad_alloc */
@@ -133,16 +134,13 @@ class RTCListHelper
public:
static inline void set(T2 *p, size_t i, const T1 &v) { p[i] = v; }
static inline T1 & at(T2 *p, size_t i) { return p[i]; }
- static inline size_t find(T2 *p, const T1 &v, size_t cSize)
+ static inline size_t find(T2 *p, const T1 &v, size_t cElements)
{
- size_t i = 0;
- while(i < cSize)
- {
+ size_t i = cElements;
+ while (i-- > 0)
if (p[i] == v)
- break;
- ++i;
- }
- return i;
+ return i;
+ return cElements;
}
static inline void copyTo(T2 *p, T2 *const p1 , size_t iTo, size_t cSize)
{
@@ -162,16 +160,13 @@ class RTCListHelper<T1, T1*>
public:
static inline void set(T1 **p, size_t i, const T1 &v) { p[i] = new T1(v); }
static inline T1 & at(T1 **p, size_t i) { return *p[i]; }
- static inline size_t find(T1 **p, const T1 &v, size_t cSize)
+ static inline size_t find(T1 **p, const T1 &v, size_t cElements)
{
- size_t i = 0;
- while(i < cSize)
- {
+ size_t i = cElements;
+ while (i-- > 0)
if (*p[i] == v)
- break;
- ++i;
- }
- return i;
+ return i;
+ return cElements;
}
static inline void copyTo(T1 **p, T1 **const p1 , size_t iTo, size_t cSize)
{
@@ -179,10 +174,10 @@ public:
p[iTo + i] = new T1(*p1[i]);
}
static inline void erase(T1 **p, size_t i) { delete p[i]; }
- static inline void eraseRange(T1 **p, size_t cFrom, size_t cSize)
+ static inline void eraseRange(T1 **p, size_t iFrom, size_t cItems)
{
- for (size_t i = cFrom; i < cFrom + cSize; ++i)
- delete p[i];
+ while (cItems-- > 0)
+ delete p[iFrom++];
}
};
@@ -194,15 +189,17 @@ public:
template <class T, typename ITYPE, bool MT>
class RTCListBase
{
- /**
- * Traits
+ /** @name Traits.
*
* Defines the return type of most of the getter methods. If the internal
* used type is a pointer, we return a reference. If not we return by
* value.
+ *
+ * @{
*/
typedef typename RTCIfPtr<ITYPE, T&, T>::result GET_RTYPE;
typedef typename RTCIfPtr<ITYPE, const T&, T>::result GET_CRTYPE;
+ /** @} */
public:
/**
@@ -213,13 +210,13 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCListBase(size_t cCapacity = DefaultCapacity)
- : m_pArray(0)
- , m_cSize(0)
- , m_cCapacity(0)
+ RTCListBase(size_t cCapacity = kDefaultCapacity)
+ : m_pArray(0)
+ , m_cElements(0)
+ , m_cCapacity(0)
{
if (cCapacity > 0)
- realloc_grow(cCapacity);
+ growArray(cCapacity);
}
/**
@@ -232,13 +229,18 @@ public:
* @throws std::bad_alloc
*/
RTCListBase(const RTCListBase<T, ITYPE, MT>& other)
- : m_pArray(0)
- , m_cSize(0)
- , m_cCapacity(0)
+ : m_pArray(0)
+ , m_cElements(0)
+ , m_cCapacity(0)
{
- realloc_no_elements_clean(other.m_cSize);
- RTCListHelper<T, ITYPE>::copyTo(m_pArray, other.m_pArray, 0, other.m_cSize);
- m_cSize = other.m_cSize;
+ other.m_guard.enterRead();
+
+ size_t const cElementsOther = other.m_cElements;
+ resizeArrayNoErase(cElementsOther);
+ RTCListHelper<T, ITYPE>::copyTo(m_pArray, other.m_pArray, 0, cElementsOther);
+ m_cElements = cElementsOther;
+
+ other.m_guard.leaveRead();
}
/**
@@ -246,16 +248,20 @@ public:
*/
~RTCListBase()
{
- RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cSize);
+ RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cElements);
if (m_pArray)
+ {
RTMemFree(m_pArray);
+ m_pArray = NULL;
+ }
+ m_cElements = m_cCapacity = 0;
}
/**
* Sets a new capacity within the list.
*
* If the new capacity is bigger than the old size, it will be simply
- * preallocated more space for the new items. If the new capacity is
+ * preallocated more space for the new items. If the new capacity is
* smaller than the previous size, items at the end of the list will be
* deleted.
*
@@ -265,7 +271,7 @@ public:
void setCapacity(size_t cCapacity)
{
m_guard.enterWrite();
- realloc(cCapacity);
+ resizeArray(cCapacity);
m_guard.leaveWrite();
}
@@ -274,26 +280,47 @@ public:
*
* @return The actual capacity.
*/
- size_t capacity() const { return m_cCapacity; }
+ size_t capacity() const
+ {
+ m_guard.enterRead();
+ size_t cRet = m_cCapacity;
+ m_guard.leaveRead();
+ return cRet;
+ }
/**
* Check if an list contains any items.
*
* @return True if there is more than zero items, false otherwise.
*/
- bool isEmpty() const { return m_cSize == 0; }
+ bool isEmpty() const
+ {
+ m_guard.enterRead();
+ bool fEmpty = m_cElements == 0;
+ m_guard.leaveRead();
+ return fEmpty;
+ }
/**
* Return the current count of elements within the list.
*
* @return The current element count.
*/
- size_t size() const { return m_cSize; }
+ size_t size() const
+ {
+ m_guard.enterRead();
+ size_t cRet = m_cElements;
+ m_guard.leaveRead();
+ return cRet;
+ }
/**
* Inserts an item to the list at position @a i.
*
- * @param i The position of the new item.
+ * @param i The position of the new item. The must be within or at the
+ * exact end of the list. Indexes specified beyond the end of
+ * the list will be changed to an append() operation and strict
+ * builds will raise an assert.
* @param val The new item.
* @return a reference to this list.
* @throws std::bad_alloc
@@ -301,13 +328,56 @@ public:
RTCListBase<T, ITYPE, MT> &insert(size_t i, const T &val)
{
m_guard.enterWrite();
- if (m_cSize == m_cCapacity)
- realloc_grow(m_cCapacity + DefaultCapacity);
- memmove(&m_pArray[i + 1], &m_pArray[i], (m_cSize - i) * sizeof(ITYPE));
+
+ AssertMsgStmt(i <= m_cElements, ("i=%zu m_cElements=%zu\n", i, m_cElements), i = m_cElements);
+
+ if (m_cElements == m_cCapacity)
+ growArray(m_cCapacity + kDefaultCapacity);
+
+ memmove(&m_pArray[i + 1], &m_pArray[i], (m_cElements - i) * sizeof(ITYPE));
RTCListHelper<T, ITYPE>::set(m_pArray, i, val);
- ++m_cSize;
+ ++m_cElements;
+
m_guard.leaveWrite();
+ return *this;
+ }
+
+ /**
+ * Inserts a list to the list at position @a i.
+ *
+ * @param i The position of the new item. The must be within or at the
+ * exact end of the list. Indexes specified beyond the end of
+ * the list will be changed to an append() operation and strict
+ * builds will raise an assert.
+ * @param other The other list. This MUST not be the same as the destination
+ * list, will assert and return without doing anything if this
+ * happens.
+ * @return a reference to this list.
+ * @throws std::bad_alloc
+ */
+ RTCListBase<T, ITYPE, MT> &insert(size_t i, const RTCListBase<T, ITYPE, MT> &other)
+ {
+ AssertReturn(this != &other, *this);
+
+ other.m_guard.enterRead();
+ m_guard.enterWrite();
+
+ AssertMsgStmt(i <= m_cElements, ("i=%zu m_cElements=%zu\n", i, m_cElements), i = m_cElements);
+ size_t cElementsOther = other.m_cElements;
+ if (RT_LIKELY(cElementsOther > 0))
+ {
+ if (m_cCapacity - m_cElements < cElementsOther)
+ growArray(m_cCapacity + (cElementsOther - (m_cCapacity - m_cElements)));
+ if (i < m_cElements)
+ memmove(&m_pArray[i + cElementsOther], &m_pArray[i], (m_cElements - i) * sizeof(ITYPE));
+
+ RTCListHelper<T, ITYPE>::copyTo(&m_pArray[i], other.m_pArray, 0, cElementsOther);
+ m_cElements += cElementsOther;
+ }
+
+ m_guard.leaveWrite();
+ other.m_guard.leaveRead();
return *this;
}
@@ -332,15 +402,7 @@ public:
*/
RTCListBase<T, ITYPE, MT> &prepend(const RTCListBase<T, ITYPE, MT> &other)
{
- m_guard.enterWrite();
- if (m_cCapacity - m_cSize < other.m_cSize)
- realloc_grow(m_cCapacity + (other.m_cSize - (m_cCapacity - m_cSize)));
- memmove(&m_pArray[other.m_cSize], &m_pArray[0], m_cSize * sizeof(ITYPE));
- RTCListHelper<T, ITYPE>::copyTo(m_pArray, other.m_pArray, 0, other.m_cSize);
- m_cSize += other.m_cSize;
- m_guard.leaveWrite();
-
- return *this;
+ return insert(0, other);
}
/**
@@ -353,10 +415,10 @@ public:
RTCListBase<T, ITYPE, MT> &append(const T &val)
{
m_guard.enterWrite();
- if (m_cSize == m_cCapacity)
- realloc_grow(m_cCapacity + DefaultCapacity);
- RTCListHelper<T, ITYPE>::set(m_pArray, m_cSize, val);
- ++m_cSize;
+ if (m_cElements == m_cCapacity)
+ growArray(m_cCapacity + kDefaultCapacity);
+ RTCListHelper<T, ITYPE>::set(m_pArray, m_cElements, val);
+ ++m_cElements;
m_guard.leaveWrite();
return *this;
@@ -365,28 +427,29 @@ public:
/**
* Append a list of type T to the list.
*
- * @param other The list to append.
+ * @param other The list to append. Must not be the same as the destination
+ * list, will assert and return without doing anything.
* @return a reference to this list.
* @throws std::bad_alloc
*/
RTCListBase<T, ITYPE, MT> &append(const RTCListBase<T, ITYPE, MT> &other)
{
+ AssertReturn(this != &other, *this);
+
+ other.m_guard.enterRead();
m_guard.enterWrite();
- if (RT_LIKELY(other.m_cSize > 0))
- {
- if (m_cCapacity - m_cSize < other.m_cSize)
- realloc_grow(m_cCapacity + (other.m_cSize - (m_cCapacity - m_cSize)));
- RTCListHelper<T, ITYPE>::copyTo(m_pArray, other.m_pArray, m_cSize, other.m_cSize);
- m_cSize += other.m_cSize;
- }
- m_guard.leaveWrite();
+ insert(m_cElements, other);
+
+ m_guard.leaveWrite();
+ other.m_guard.leaveRead();
return *this;
}
/**
- * Copy the items of the other list into this list. All previous items of
- * this list are deleted.
+ * Copy the items of the other list into this list.
+ *
+ * All previous items of this list are deleted.
*
* @param other The list to copy.
* @return a reference to this list.
@@ -397,51 +460,61 @@ public:
if (RT_UNLIKELY(this == &other))
return *this;
+ other.m_guard.enterRead();
m_guard.enterWrite();
+
/* Delete all items. */
- RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cSize);
+ RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cElements);
+
/* Need we to realloc memory. */
- if (other.m_cSize != m_cCapacity)
- realloc_no_elements_clean(other.m_cSize);
- m_cSize = other.m_cSize;
+ if (other.m_cElements != m_cCapacity)
+ resizeArrayNoErase(other.m_cElements);
+ m_cElements = other.m_cElements;
+
/* Copy new items. */
- RTCListHelper<T, ITYPE>::copyTo(m_pArray, other.m_pArray, 0, other.m_cSize);
- m_guard.leaveWrite();
+ RTCListHelper<T, ITYPE>::copyTo(m_pArray, other.m_pArray, 0, other.m_cElements);
+ m_guard.leaveWrite();
+ other.m_guard.leaveRead();
return *this;
}
/**
* Replace an item in the list.
*
- * @note No boundary checks are done. Make sure @a i is equal or greater zero
- * and smaller than RTCList::size.
- *
- * @param i The position of the item to replace.
+ * @param i The position of the item to replace. If this is out of range,
+ * the request will be ignored, strict builds will assert.
* @param val The new value.
* @return a reference to this list.
*/
RTCListBase<T, ITYPE, MT> &replace(size_t i, const T &val)
{
m_guard.enterWrite();
- RTCListHelper<T, ITYPE>::erase(m_pArray, i);
- RTCListHelper<T, ITYPE>::set(m_pArray, i, val);
- m_guard.leaveWrite();
+ if (i < m_cElements)
+ {
+ RTCListHelper<T, ITYPE>::erase(m_pArray, i);
+ RTCListHelper<T, ITYPE>::set(m_pArray, i, val);
+ }
+ else
+ AssertMsgFailed(("i=%zu m_cElements=%zu\n", i, m_cElements));
+
+ m_guard.leaveWrite();
return *this;
}
/**
* Return the first item as constant object.
*
- * @note No boundary checks are done. Make sure there is at least one
- * element.
+ * @return A reference or pointer to the first item.
*
- * @return The first item.
+ * @note No boundary checks are done. Make sure there is at least one
+ * element.
*/
GET_CRTYPE first() const
{
m_guard.enterRead();
+ Assert(m_cElements > 0);
GET_CRTYPE res = RTCListHelper<T, ITYPE>::at(m_pArray, 0);
m_guard.leaveRead();
return res;
@@ -450,14 +523,15 @@ public:
/**
* Return the first item.
*
- * @note No boundary checks are done. Make sure there is at least one
- * element.
+ * @return A reference or pointer to the first item.
*
- * @return The first item.
+ * @note No boundary checks are done. Make sure there is at least one
+ * element.
*/
GET_RTYPE first()
{
m_guard.enterRead();
+ Assert(m_cElements > 0);
GET_RTYPE res = RTCListHelper<T, ITYPE>::at(m_pArray, 0);
m_guard.leaveRead();
return res;
@@ -466,15 +540,16 @@ public:
/**
* Return the last item as constant object.
*
- * @note No boundary checks are done. Make sure there is at least one
- * element.
+ * @return A reference or pointer to the last item.
*
- * @return The last item.
+ * @note No boundary checks are done. Make sure there is at least one
+ * element.
*/
GET_CRTYPE last() const
{
m_guard.enterRead();
- GET_CRTYPE res = RTCListHelper<T, ITYPE>::at(m_pArray, m_cSize - 1);
+ Assert(m_cElements > 0);
+ GET_CRTYPE res = RTCListHelper<T, ITYPE>::at(m_pArray, m_cElements - 1);
m_guard.leaveRead();
return res;
}
@@ -482,15 +557,16 @@ public:
/**
* Return the last item.
*
- * @note No boundary checks are done. Make sure there is at least one
- * element.
+ * @return A reference or pointer to the last item.
*
- * @return The last item.
+ * @note No boundary checks are done. Make sure there is at least one
+ * element.
*/
GET_RTYPE last()
{
m_guard.enterRead();
- GET_RTYPE res = RTCListHelper<T, ITYPE>::at(m_pArray, m_cSize - 1);
+ Assert(m_cElements > 0);
+ GET_RTYPE res = RTCListHelper<T, ITYPE>::at(m_pArray, m_cElements - 1);
m_guard.leaveRead();
return res;
}
@@ -498,15 +574,16 @@ public:
/**
* Return the item at position @a i as constant object.
*
- * @note No boundary checks are done. Make sure @a i is equal or greater zero
- * and smaller than RTCList::size.
- *
- * @param i The position of the item to return.
+ * @param i The position of the item to return. This better not be out of
+ * bounds, however should it be the last element of the array
+ * will be return and strict builds will raise an assertion.
+ * Should the array be empty, a crash is very likely.
* @return The item at position @a i.
*/
GET_CRTYPE at(size_t i) const
{
m_guard.enterRead();
+ AssertMsgStmt(i < m_cElements, ("i=%zu m_cElements=%zu\n", i, m_cElements), i = m_cElements - 1);
GET_CRTYPE res = RTCListHelper<T, ITYPE>::at(m_pArray, i);
m_guard.leaveRead();
return res;
@@ -515,15 +592,16 @@ public:
/**
* Return the item at position @a i.
*
- * @note No boundary checks are done. Make sure @a i is equal or greater zero
- * and smaller than RTCList::size.
- *
- * @param i The position of the item to return.
+ * @param i The position of the item to return. This better not be out of
+ * bounds, however should it be the last element of the array
+ * will be return and strict builds will raise an assertion.
+ * Should the array be empty, a crash is very likely.
* @return The item at position @a i.
*/
GET_RTYPE at(size_t i)
{
m_guard.enterRead();
+ AssertMsgStmt(i < m_cElements, ("i=%zu m_cElements=%zu\n", i, m_cElements), i = m_cElements - 1);
GET_RTYPE res = RTCListHelper<T, ITYPE>::at(m_pArray, i);
m_guard.leaveRead();
return res;
@@ -532,31 +610,31 @@ public:
/**
* Return the item at position @a i as mutable reference.
*
- * @note No boundary checks are done. Make sure @a i is equal or greater zero
- * and smaller than RTCList::size.
- *
- * @param i The position of the item to return.
+ * @param i The position of the item to return. This better not be out of
+ * bounds, however should it be the last element of the array
+ * will be return and strict builds will raise an assertion.
+ * Should the array be empty, a crash is very likely.
* @return The item at position @a i.
*/
T &operator[](size_t i)
{
m_guard.enterRead();
+ AssertMsgStmt(i < m_cElements, ("i=%zu m_cElements=%zu\n", i, m_cElements), i = m_cElements - 1);
T &res = RTCListHelper<T, ITYPE>::at(m_pArray, i);
m_guard.leaveRead();
return res;
}
/**
- * Return the item at position @a i. If @a i isn't valid within the list a
- * default value is returned.
+ * Return the item at position @a i or default value if out of range.
*
* @param i The position of the item to return.
- * @return The item at position @a i.
+ * @return The item at position @a i or default value.
*/
T value(size_t i) const
{
m_guard.enterRead();
- if (RT_UNLIKELY(i >= m_cSize))
+ if (RT_UNLIKELY(i >= m_cElements))
{
m_guard.leaveRead();
return T();
@@ -567,17 +645,16 @@ public:
}
/**
- * Return the item at position @a i. If @a i isn't valid within the list
- * @a defaultVal is returned.
+ * Return the item at position @a i, or @a defaultVal if out of range.
*
* @param i The position of the item to return.
* @param defaultVal The value to return in case @a i is invalid.
- * @return The item at position @a i.
+ * @return The item at position @a i or @a defaultVal.
*/
T value(size_t i, const T &defaultVal) const
{
m_guard.enterRead();
- if (RT_UNLIKELY(i >= m_cSize))
+ if (RT_UNLIKELY(i >= m_cElements))
{
m_guard.leaveRead();
return defaultVal;
@@ -596,16 +673,16 @@ public:
bool contains(const T &val) const
{
m_guard.enterRead();
- bool res = RTCListHelper<T, ITYPE>::find(m_pArray, val, m_cSize) != m_cSize;
+ bool fRc = RTCListHelper<T, ITYPE>::find(m_pArray, val, m_cElements) < m_cElements;
m_guard.leaveRead();
- return res;
+ return fRc;
}
/**
* Remove the first item.
*
- * @note No boundary checks are done. Make sure there is at least one
- * element.
+ * @note You should make sure the list isn't empty. Strict builds will assert.
+ * The other builds will quietly ignore the request.
*/
void removeFirst()
{
@@ -615,51 +692,52 @@ public:
/**
* Remove the last item.
*
- * @note No boundary checks are done. Make sure there is at least one
- * element.
+ * @note You should make sure the list isn't empty. Strict builds will assert.
+ * The other builds will quietly ignore the request.
*/
void removeLast()
{
- removeAt(m_cSize - 1);
+ m_guard.enterWrite();
+ removeAtLocked(m_cElements - 1);
+ m_guard.leaveWrite();
}
/**
* Remove the item at position @a i.
*
- * @note No boundary checks are done. Make sure @a i is equal or greater zero
- * and smaller than RTCList::size.
- *
- * @param i The position of the item to remove.
+ * @param i The position of the item to remove. Out of bounds values will
+ * be ignored and an assertion will be raised in strict builds.
*/
void removeAt(size_t i)
{
m_guard.enterWrite();
- RTCListHelper<T, ITYPE>::erase(m_pArray, i);
- /* Not last element? */
- if (i < m_cSize - 1)
- memmove(&m_pArray[i], &m_pArray[i + 1], (m_cSize - i - 1) * sizeof(ITYPE));
- --m_cSize;
+ removeAtLocked(i);
m_guard.leaveWrite();
}
/**
* Remove a range of items from the list.
*
- * @note No boundary checks are done. Make sure @a iFrom is equal or
- * greater zero and smaller than RTCList::size. @a iTo has to be
- * greater than @a iFrom and equal or smaller than RTCList::size.
- *
- * @param iFrom The start position of the items to remove.
- * @param iTo The end position of the items to remove (excluded).
+ * @param iStart The start position of the items to remove.
+ * @param iEnd The end position of the items to remove (excluded).
*/
- void removeRange(size_t iFrom, size_t iTo)
+ void removeRange(size_t iStart, size_t iEnd)
{
+ AssertReturnVoid(iStart <= iEnd);
m_guard.enterWrite();
- RTCListHelper<T, ITYPE>::eraseRange(m_pArray, iFrom, iTo - iFrom);
- /* Not last elements? */
- if (m_cSize - iTo > 0)
- memmove(&m_pArray[iFrom], &m_pArray[iTo], (m_cSize - iTo) * sizeof(ITYPE));
- m_cSize -= iTo - iFrom;
+
+ AssertMsgStmt(iEnd <= m_cElements, ("iEnd=%zu m_cElements=%zu\n", iEnd, m_cElements), iEnd = m_cElements);
+ AssertMsgStmt(iStart < m_cElements, ("iStart=%zu m_cElements=%zu\n", iStart, m_cElements), iStart = m_cElements);
+ size_t const cElements = iEnd - iStart;
+ if (cElements > 0)
+ {
+ Assert(iStart < m_cElements);
+ RTCListHelper<T, ITYPE>::eraseRange(m_pArray, iStart, cElements);
+ if (m_cElements > iEnd)
+ memmove(&m_pArray[iStart], &m_pArray[iEnd], (m_cElements - iEnd) * sizeof(ITYPE));
+ m_cElements -= cElements;
+ }
+
m_guard.leaveWrite();
}
@@ -669,18 +747,21 @@ public:
void clear()
{
m_guard.enterWrite();
+
/* Values cleanup */
- RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cSize);
- if (m_cSize != DefaultCapacity)
- realloc_no_elements_clean(DefaultCapacity);
- m_cSize = 0;
+ RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cElements);
+ if (m_cElements != kDefaultCapacity)
+ resizeArrayNoErase(kDefaultCapacity);
+ m_cElements = 0;
+
m_guard.leaveWrite();
}
/**
- * Return the raw array. For native types this is a pointer to continuous
- * memory of the items. For pointer types this is a continuous memory of
- * pointers to the items.
+ * Return the raw array.
+ *
+ * For native types this is a pointer to continuous memory of the items. For
+ * pointer types this is a continuous memory of pointers to the items.
*
* @warning If you change anything in the underlaying list, this memory
* will very likely become invalid. So take care when using this
@@ -688,12 +769,12 @@ public:
*
* @returns the raw memory.
*/
- ITYPE* raw() const
+ ITYPE *raw() const
{
m_guard.enterRead();
- ITYPE* res = m_pArray;
+ ITYPE *pRet = m_pArray;
m_guard.leaveRead();
- return res;
+ return pRet;
}
RTCListBase<T, ITYPE, MT> &operator<<(const T &val)
@@ -707,89 +788,114 @@ public:
/**
* The default capacity of the list. This is also used as grow factor.
*/
- static const size_t DefaultCapacity;
+ static const size_t kDefaultCapacity;
protected:
/**
- * Generic realloc, which does some kind of boundary checking.
+ * Generic resizes the array, surplus elements are erased.
+ *
+ * @param cElementsNew The new array size.
+ * @throws std::bad_alloc.
*/
- void realloc(size_t cNewSize)
+ void resizeArray(size_t cElementsNew)
{
/* Same size? */
- if (cNewSize == m_cCapacity)
+ if (cElementsNew == m_cCapacity)
return;
/* If we get smaller we have to delete some of the objects at the end
of the list. */
- if ( cNewSize < m_cSize
+ if ( cElementsNew < m_cElements
&& m_pArray)
- RTCListHelper<T, ITYPE>::eraseRange(m_pArray, cNewSize, m_cSize - cNewSize);
- realloc_no_elements_clean(cNewSize);
+ RTCListHelper<T, ITYPE>::eraseRange(m_pArray, cElementsNew, m_cElements - cElementsNew);
+
+ resizeArrayNoErase(cElementsNew);
}
- void realloc_no_elements_clean(size_t cNewSize)
+ /**
+ * Resizes the array without doing the erase() thing on surplus elements.
+ *
+ * @param cElementsNew The new array size.
+ * @throws std::bad_alloc.
+ */
+ void resizeArrayNoErase(size_t cElementsNew)
{
/* Same size? */
- if (cNewSize == m_cCapacity)
+ if (cElementsNew == m_cCapacity)
return;
- /* If we get smaller we have to delete some of the objects at the end
- of the list. */
- if ( cNewSize < m_cSize
- && m_pArray)
- m_cSize -= m_cSize - cNewSize;
-
- /* If we get zero we delete the array it self. */
- if ( cNewSize == 0
- && m_pArray)
- {
- RTMemFree(m_pArray);
- m_pArray = 0;
- }
- m_cCapacity = cNewSize;
-
/* Resize the array. */
- if (cNewSize > 0)
+ if (cElementsNew > 0)
{
- m_pArray = static_cast<ITYPE*>(RTMemRealloc(m_pArray, sizeof(ITYPE) * cNewSize));
- if (!m_pArray)
+ void *pvNew = RTMemRealloc(m_pArray, sizeof(ITYPE) * cElementsNew);
+ if (!pvNew)
{
- /** @todo you leak memory. */
- m_cCapacity = 0;
- m_cSize = 0;
#ifdef RT_EXCEPTIONS_ENABLED
throw std::bad_alloc();
#endif
+ return;
}
+ m_pArray = static_cast<ITYPE*>(pvNew);
+ }
+ /* If we get zero we delete the array it self. */
+ else if (m_pArray)
+ {
+ RTMemFree(m_pArray);
+ m_pArray = NULL;
}
+
+ m_cCapacity = cElementsNew;
+ if (m_cElements > cElementsNew)
+ m_cElements = cElementsNew;
}
/**
* Special realloc method which require that the array will grow.
*
+ * @param cElementsNew The new array size.
+ * @throws std::bad_alloc.
* @note No boundary checks are done!
*/
- void realloc_grow(size_t cNewSize)
+ void growArray(size_t cElementsNew)
{
- /* Resize the array. */
- m_cCapacity = cNewSize;
- m_pArray = static_cast<ITYPE*>(RTMemRealloc(m_pArray, sizeof(ITYPE) * cNewSize));
- if (!m_pArray)
+ Assert(cElementsNew > m_cCapacity);
+ void *pvNew = RTMemRealloc(m_pArray, sizeof(ITYPE) * cElementsNew);
+ if (pvNew)
+ {
+ m_cCapacity = cElementsNew;
+ m_pArray = static_cast<ITYPE*>(pvNew);
+ }
+ else
{
- /** @todo you leak memory. */
- m_cCapacity = 0;
- m_cSize = 0;
#ifdef RT_EXCEPTIONS_ENABLED
throw std::bad_alloc();
#endif
}
}
+ /**
+ * Remove the item at position @a i.
+ *
+ * @param i The position of the item to remove. Out of bounds values will
+ * be ignored and an assertion will be raised in strict builds.
+ * @remarks
+ */
+ void removeAtLocked(size_t i)
+ {
+ AssertMsgReturnVoid(i < m_cElements, ("i=%zu m_cElements=%zu\n", i, m_cElements));
+
+ RTCListHelper<T, ITYPE>::erase(m_pArray, i);
+ if (i < m_cElements - 1)
+ memmove(&m_pArray[i], &m_pArray[i + 1], (m_cElements - i - 1) * sizeof(ITYPE));
+ --m_cElements;
+ }
+
+
/** The internal list array. */
ITYPE *m_pArray;
/** The current count of items in use. */
- size_t m_cSize;
+ size_t m_cElements;
/** The current capacity of the internal array. */
size_t m_cCapacity;
/** The guard used to serialize the access to the items. */
@@ -797,7 +903,7 @@ protected:
};
template <class T, typename ITYPE, bool MT>
-const size_t RTCListBase<T, ITYPE, MT>::DefaultCapacity = 10;
+const size_t RTCListBase<T, ITYPE, MT>::kDefaultCapacity = 10;
/**
* Template class which automatically determines the type of list to use.
@@ -819,11 +925,11 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCList(size_t cCapacity = BASE::DefaultCapacity)
- : BASE(cCapacity) {}
+ RTCList(size_t cCapacity = BASE::kDefaultCapacity)
+ : BASE(cCapacity) {}
RTCList(const BASE &other)
- : BASE(other) {}
+ : BASE(other) {}
/* Define our own new and delete. */
RTMEMEF_NEW_AND_DELETE_OPERATORS();
@@ -850,8 +956,8 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCList(size_t cCapacity = BASE::DefaultCapacity)
- : BASE(cCapacity) {}
+ RTCList(size_t cCapacity = BASE::kDefaultCapacity)
+ : BASE(cCapacity) {}
/* Define our own new and delete. */
RTMEMEF_NEW_AND_DELETE_OPERATORS();
@@ -878,8 +984,8 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCList(size_t cCapacity = BASE::DefaultCapacity)
- : BASE(cCapacity) {}
+ RTCList(size_t cCapacity = BASE::kDefaultCapacity)
+ : BASE(cCapacity) {}
/* Define our own new and delete. */
RTMEMEF_NEW_AND_DELETE_OPERATORS();
diff --git a/include/iprt/cpp/ministring.h b/include/iprt/cpp/ministring.h
index 29c97409..35984905 100644
--- a/include/iprt/cpp/ministring.h
+++ b/include/iprt/cpp/ministring.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2007-2011 Oracle Corporation
+ * Copyright (C) 2007-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -425,7 +425,7 @@ public:
if (length())
{
/* Folding an UTF-8 string may result in a shorter encoding (see
- testcase), so recalculate the length afterwars. */
+ testcase), so recalculate the length afterwards. */
::RTStrToUpper(m_psz);
size_t cchNew = strlen(m_psz);
Assert(cchNew <= m_cch);
@@ -444,7 +444,7 @@ public:
if (length())
{
/* Folding an UTF-8 string may result in a shorter encoding (see
- testcase), so recalculate the length afterwars. */
+ testcase), so recalculate the length afterwards. */
::RTStrToLower(m_psz);
size_t cchNew = strlen(m_psz);
Assert(cchNew <= m_cch);
diff --git a/include/iprt/cpp/mtlist.h b/include/iprt/cpp/mtlist.h
index eb4e587c..de13464d 100644
--- a/include/iprt/cpp/mtlist.h
+++ b/include/iprt/cpp/mtlist.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2011 Oracle Corporation
+ * Copyright (C) 2011-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -27,7 +27,6 @@
#define ___iprt_cpp_mtlist_h
#include <iprt/cpp/list.h>
-
#include <iprt/semaphore.h>
/** @addtogroup grp_rt_cpp_list
@@ -41,8 +40,26 @@ template <>
class RTCListGuard<true>
{
public:
- RTCListGuard() { int rc = RTSemRWCreate(&m_hRWSem); AssertRC(rc); }
- ~RTCListGuard() { RTSemRWDestroy(m_hRWSem); }
+ RTCListGuard() : m_hRWSem(NIL_RTSEMRW)
+ {
+#if defined(RT_LOCK_STRICT_ORDER) && defined(IN_RING3)
+ RTLOCKVALCLASS hClass;
+ int rc = RTLockValidatorClassCreate(&hClass, true /*fAutodidact*/, RT_SRC_POS, "RTCListGuard");
+ AssertStmt(RT_SUCCESS(rc), hClass = NIL_RTLOCKVALCLASS);
+ rc = RTSemRWCreateEx(&m_hRWSem, 0 /*fFlags*/, hClass, RTLOCKVAL_SUB_CLASS_NONE, NULL /*pszNameFmt*/);
+ AssertRC(rc);
+#else
+ int rc = RTSemRWCreateEx(&m_hRWSem, 0 /*fFlags*/, NIL_RTLOCKVALCLASS, 0, NULL);
+ AssertRC(rc);
+#endif
+ }
+
+ ~RTCListGuard()
+ {
+ RTSemRWDestroy(m_hRWSem);
+ m_hRWSem = NIL_RTSEMRW;
+ }
+
inline void enterRead() const { int rc = RTSemRWRequestRead(m_hRWSem, RT_INDEFINITE_WAIT); AssertRC(rc); }
inline void leaveRead() const { int rc = RTSemRWReleaseRead(m_hRWSem); AssertRC(rc); }
inline void enterWrite() { int rc = RTSemRWRequestWrite(m_hRWSem, RT_INDEFINITE_WAIT); AssertRC(rc); }
@@ -86,8 +103,8 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCMTList(size_t cCapacity = BASE::DefaultCapacity)
- : BASE(cCapacity) {}
+ RTCMTList(size_t cCapacity = BASE::kDefaultCapacity)
+ : BASE(cCapacity) {}
/* Define our own new and delete. */
RTMEMEF_NEW_AND_DELETE_OPERATORS();
@@ -114,8 +131,8 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCMTList(size_t cCapacity = BASE::DefaultCapacity)
- : BASE(cCapacity) {}
+ RTCMTList(size_t cCapacity = BASE::kDefaultCapacity)
+ : BASE(cCapacity) {}
/* Define our own new and delete. */
RTMEMEF_NEW_AND_DELETE_OPERATORS();
@@ -142,8 +159,8 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCMTList(size_t cCapacity = BASE::DefaultCapacity)
- : BASE(cCapacity) {}
+ RTCMTList(size_t cCapacity = BASE::kDefaultCapacity)
+ : BASE(cCapacity) {}
/* Define our own new and delete. */
RTMEMEF_NEW_AND_DELETE_OPERATORS();
diff --git a/include/iprt/cpp/utils.h b/include/iprt/cpp/utils.h
index e5b269a0..4edc8e5f 100644
--- a/include/iprt/cpp/utils.h
+++ b/include/iprt/cpp/utils.h
@@ -96,6 +96,40 @@ inline C *unconst(const C *that)
return const_cast<C *>(that);
}
+
+/**
+ * Macro for generating a non-const getter version from a const getter.
+ *
+ * @param a_RetType The getter return type.
+ * @param a_Class The class name.
+ * @param a_Getter The getter name.
+ * @param a_ArgDecls The argument declaration for the getter method.
+ * @param a_ArgList The argument list for the call.
+ */
+#define RT_CPP_GETTER_UNCONST(a_RetType, a_Class, a_Getter, a_ArgDecls, a_ArgList) \
+ a_RetType a_Getter a_ArgDecls \
+ { \
+ return static_cast< a_Class const *>(this)-> a_Getter a_ArgList; \
+ }
+
+
+/**
+ * Macro for generating a non-const getter version from a const getter,
+ * unconsting the return value as well.
+ *
+ * @param a_RetType The getter return type.
+ * @param a_Class The class name.
+ * @param a_Getter The getter name.
+ * @param a_ArgDecls The argument declaration for the getter method.
+ * @param a_ArgList The argument list for the call.
+ */
+#define RT_CPP_GETTER_UNCONST_RET(a_RetType, a_Class, a_Getter, a_ArgDecls, a_ArgList) \
+ a_RetType a_Getter a_ArgDecls \
+ { \
+ return const_cast<a_RetType>(static_cast< a_Class const *>(this)-> a_Getter a_ArgList); \
+ }
+
+
/** @} */
#endif
diff --git a/include/iprt/cpp/xml.h b/include/iprt/cpp/xml.h
index bb9f5a18..d45ce746 100644
--- a/include/iprt/cpp/xml.h
+++ b/include/iprt/cpp/xml.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2007-2011 Oracle Corporation
+ * Copyright (C) 2007-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -30,10 +30,13 @@
# error "There are no XML APIs available in Ring-0 Context!"
#endif
+#include <iprt/list.h>
+#include <iprt/cpp/exception.h>
+#include <iprt/cpp/utils.h>
+
#include <list>
#include <memory>
-#include <iprt/cpp/exception.h>
/** @defgroup grp_rt_cpp_xml C++ XML support
* @ingroup grp_rt_cpp
@@ -380,60 +383,158 @@ class AttributeNode;
class ContentNode;
/**
- * Node base class. Cannot be used directly, but ElementNode, ContentNode and
- * AttributeNode derive from this. This does implement useful public methods though.
+ * Node base class.
+ *
+ * Cannot be used directly, but ElementNode, ContentNode and AttributeNode
+ * derive from this. This does implement useful public methods though.
+ *
+ *
*/
class RT_DECL_CLASS Node
{
public:
- ~Node();
+ virtual ~Node();
- const char* getName() const;
- bool nameEquals(const char *pcszNamespace, const char *pcsz) const;
+ const char *getName() const;
+ const char *getPrefix() const;
+ const char *getNamespaceURI() const;
+ bool nameEqualsNS(const char *pcszNamespace, const char *pcsz) const;
bool nameEquals(const char *pcsz) const
{
- return nameEquals(NULL, pcsz);
+ return nameEqualsNS(NULL, pcsz);
}
+ bool nameEqualsN(const char *pcsz, size_t cchMax, const char *pcszNamespace = NULL) const;
- const char* getValue() const;
+ const char *getValue() const;
bool copyValue(int32_t &i) const;
bool copyValue(uint32_t &i) const;
bool copyValue(int64_t &i) const;
bool copyValue(uint64_t &i) const;
- int getLineNumber() const;
+ /** @name Introspection.
+ * @{ */
+ /** Is this an ElementNode instance.
+ * @returns true / false */
+ bool isElement() const
+ {
+ return m_Type == IsElement;
+ }
- int isElement() const
+ /** Is this an ContentNode instance.
+ * @returns true / false */
+ bool isContent() const
+ {
+ return m_Type == IsContent;
+ }
+
+ /** Is this an AttributeNode instance.
+ * @returns true / false */
+ bool isAttribute() const
{
return m_Type == IsElement;
}
+ int getLineNumber() const;
+ /** @} */
+
+ /** @name General tree enumeration.
+ *
+ * Use the introspection methods isElement() and isContent() before doing static
+ * casting. Parents are always or ElementNode type, but siblings and children
+ * can be of both ContentNode and ElementNode types.
+ *
+ * @remarks Attribute node are in the attributes list, while both content and
+ * element nodes are in the list of children. See ElementNode.
+ *
+ * @remarks Careful mixing tree walking with node removal!
+ * @{
+ */
+ /** Get the parent node
+ * @returns Pointer to the parent node, or NULL if root. */
+ const Node *getParent() const
+ {
+ return m_pParent;
+ }
+
+ /** Get the previous sibling.
+ * @returns Pointer to the previous sibling node, NULL if first child.
+ */
+ const Node *getPrevSibiling() const
+ {
+ if (!m_pParentListAnchor)
+ return NULL;
+ return RTListGetPrevCpp(m_pParentListAnchor, this, const Node, m_listEntry);
+ }
+
+ /** Get the next sibling.
+ * @returns Pointer to the next sibling node, NULL if last child. */
+ const Node *getNextSibiling() const
+ {
+ if (!m_pParentListAnchor)
+ return NULL;
+ return RTListGetNextCpp(m_pParentListAnchor, this, const Node, m_listEntry);
+ }
+ /** @} */
+
protected:
- typedef enum {IsElement, IsAttribute, IsContent} EnumType;
+ /** Node types. */
+ typedef enum { IsElement, IsAttribute, IsContent } EnumType;
+ /** The type of node this is an instance of. */
EnumType m_Type;
- Node *m_pParent;
- xmlNode *m_plibNode; // != NULL if this is an element or content node
- xmlAttr *m_plibAttr; // != NULL if this is an attribute node
- const char *m_pcszNamespacePrefix; // not always set
- const char *m_pcszNamespaceHref; // full http:// spec
- const char *m_pcszName; // element or attribute name, points either into plibNode or plibAttr;
- // NULL if this is a content node
+ /** The parent node (always an element), NULL if root. */
+ Node *m_pParent;
+
+ xmlNode *m_pLibNode; ///< != NULL if this is an element or content node
+ xmlAttr *m_pLibAttr; ///< != NULL if this is an attribute node
+ const char *m_pcszNamespacePrefix; ///< not always set
+ const char *m_pcszNamespaceHref; ///< full http:// spec
+ const char *m_pcszName; ///< element or attribute name, points either into pLibNode or pLibAttr;
+ ///< NULL if this is a content node
+
+ /** Child list entry of this node. (List head m_pParent->m_children.) */
+ RTLISTNODE m_listEntry;
+ /** Pointer to the parent list anchor.
+ * This allows us to use m_listEntry both for children and attributes. */
+ PRTLISTANCHOR m_pParentListAnchor;
// hide the default constructor so people use only our factory methods
Node(EnumType type,
Node *pParent,
- xmlNode *plibNode,
- xmlAttr *plibAttr);
+ PRTLISTANCHOR pListAnchor,
+ xmlNode *pLibNode,
+ xmlAttr *pLibAttr);
Node(const Node &x); // no copying
- void buildChildren(const ElementNode &elmRoot);
+ friend class AttributeNode;
+ friend class ElementNode; /* C list hack. */
+};
- /* Obscure class data */
- struct Data;
- Data *m;
+/**
+ * Node subclass that represents an attribute of an element.
+ *
+ * For attributes, Node::getName() returns the attribute name, and Node::getValue()
+ * returns the attribute value, if any.
+ *
+ * Since the Node constructor is private, one can create new attribute nodes
+ * only through the following factory methods:
+ *
+ * -- ElementNode::setAttribute()
+ */
+class RT_DECL_CLASS AttributeNode : public Node
+{
+public:
- friend class AttributeNode;
+protected:
+ // hide the default constructor so people use only our factory methods
+ AttributeNode(const ElementNode *pElmRoot,
+ Node *pParent,
+ PRTLISTANCHOR pListAnchor,
+ xmlAttr *pLibAttr);
+ AttributeNode(const AttributeNode &x); // no copying
+
+ friend class Node;
+ friend class ElementNode;
};
/**
@@ -451,54 +552,313 @@ protected:
class RT_DECL_CLASS ElementNode : public Node
{
public:
- int getChildElements(ElementNodesList &children,
- const char *pcszMatch = NULL) const;
+ int getChildElements(ElementNodesList &children, const char *pcszMatch = NULL) const;
- const ElementNode* findChildElement(const char *pcszNamespace,
- const char *pcszMatch) const;
- const ElementNode* findChildElement(const char *pcszMatch) const
+ const ElementNode *findChildElementNS(const char *pcszNamespace, const char *pcszMatch) const;
+ const ElementNode *findChildElement(const char *pcszMatch) const
{
- return findChildElement(NULL, pcszMatch);
+ return findChildElementNS(NULL, pcszMatch);
}
- const ElementNode* findChildElementFromId(const char *pcszId) const;
-
- const AttributeNode* findAttribute(const char *pcszMatch) const;
- bool getAttributeValue(const char *pcszMatch, const char *&ppcsz) const;
- bool getAttributeValue(const char *pcszMatch, RTCString &str) const;
- bool getAttributeValuePath(const char *pcszMatch, RTCString &str) const;
- bool getAttributeValue(const char *pcszMatch, int32_t &i) const;
- bool getAttributeValue(const char *pcszMatch, uint32_t &i) const;
- bool getAttributeValue(const char *pcszMatch, int64_t &i) const;
- bool getAttributeValue(const char *pcszMatch, uint64_t &i) const;
- bool getAttributeValue(const char *pcszMatch, bool &f) const;
-
- ElementNode* createChild(const char *pcszElementName);
-
- ContentNode* addContent(const char *pcszContent);
- ContentNode* addContent(const RTCString &strContent)
+ const ElementNode *findChildElementFromId(const char *pcszId) const;
+
+ /** Finds the first decendant matching the name at the end of @a pcszPath and
+ * optionally namespace.
+ *
+ * @returns Pointer to the child string value, NULL if not found or no value.
+ * @param pcszPath The attribute name. Slashes can be used to make a
+ * simple path to any decendant.
+ * @param pcszNamespace The namespace to match, NULL (default) match any
+ * namespace. When using a path, this matches all
+ * elements along the way.
+ * @see findChildElement, findChildElementP
+ */
+ const ElementNode *findChildElementP(const char *pcszPath, const char *pcszNamespace = NULL) const;
+
+ /** Finds the first child with matching the give name and optionally namspace,
+ * returning its value.
+ *
+ * @returns Pointer to the child string value, NULL if not found or no value.
+ * @param pcszPath The attribute name. Slashes can be used to make a
+ * simple path to any decendant.
+ * @param pcszNamespace The namespace to match, NULL (default) match any
+ * namespace. When using a path, this matches all
+ * elements along the way.
+ * @see findChildElement, findChildElementP
+ */
+ const char *findChildElementValueP(const char *pcszPath, const char *pcszNamespace = NULL) const
+ {
+ const ElementNode *pElem = findChildElementP(pcszPath, pcszNamespace);
+ if (pElem)
+ return pElem->getValue();
+ return NULL;
+ }
+
+ /** Combines findChildElementP and findAttributeValue.
+ *
+ * @returns Pointer to attribute string value, NULL if either the element or
+ * the attribute was not found.
+ * @param pcszPath The attribute name. Slashes can be used to make a
+ * simple path to any decendant.
+ * @param pcszAttribute The attribute name.
+ * @param pcszPathNamespace The namespace to match @pcszPath with, NULL
+ * (default) match any namespace. When using a
+ * path, this matches all elements along the way.
+ * @param pcszAttribNamespace The namespace prefix to apply to the attribute,
+ * NULL (default) match any namespace.
+ * @see findChildElementP and findAttributeValue
+ */
+ const char *findChildElementAttributeValueP(const char *pcszPath, const char *pcszAttribute,
+ const char *pcszPathNamespace = NULL,
+ const char *pcszAttributeNamespace = NULL) const
+ {
+ const ElementNode *pElem = findChildElementP(pcszPath, pcszPathNamespace);
+ if (pElem)
+ return pElem->findAttributeValue(pcszAttribute, pcszAttributeNamespace);
+ return NULL;
+ }
+
+
+ /** @name Tree enumeration.
+ * @{ */
+
+ /** Get the next tree element in a full tree enumeration.
+ *
+ * By starting with the root node, this can be used to enumerate the entire tree
+ * (or sub-tree if @a pElmRoot is used).
+ *
+ * @returns Pointer to the next element in the tree, NULL if we're done.
+ * @param pElmRoot The root of the tree we're enumerating. NULL if
+ * it's the entire tree.
+ */
+ ElementNode const *getNextTreeElement(ElementNode const *pElmRoot = NULL) const;
+ RT_CPP_GETTER_UNCONST_RET(ElementNode *, ElementNode, getNextTreeElement, (const ElementNode *pElmRoot = NULL), (pElmRoot))
+
+ /** Get the first child node.
+ * @returns Pointer to the first child node, NULL if no children. */
+ const Node *getFirstChild() const
+ {
+ return RTListGetFirstCpp(&m_children, const Node, m_listEntry);
+ }
+ RT_CPP_GETTER_UNCONST_RET(Node *, ElementNode, getFirstChild,(),())
+
+ /** Get the last child node.
+ * @returns Pointer to the last child node, NULL if no children. */
+ const Node *getLastChild() const
+ {
+ return RTListGetLastCpp(&m_children, const Node, m_listEntry);
+ }
+
+ /** Get the first child node.
+ * @returns Pointer to the first child node, NULL if no children. */
+ const ElementNode *getFirstChildElement() const;
+
+ /** Get the last child node.
+ * @returns Pointer to the last child node, NULL if no children. */
+ const ElementNode *getLastChildElement() const;
+
+ /** Get the previous sibling element.
+ * @returns Pointer to the previous sibling element, NULL if first child
+ * element.
+ * @see getNextSibilingElement, getPrevSibling
+ */
+ const ElementNode *getPrevSibilingElement() const;
+
+ /** Get the next sibling element.
+ * @returns Pointer to the next sibling element, NULL if last child element.
+ * @see getPrevSibilingElement, getNextSibling
+ */
+ const ElementNode *getNextSibilingElement() const;
+
+ /** Find the previous element matching the given name and namespace (optionally).
+ * @returns Pointer to the previous sibling element, NULL if first child
+ * element.
+ * @param pcszName The element name to match.
+ * @param pcszNamespace The namespace name, default is NULL which means
+ * anything goes.
+ * @note Changed the order of the arguments.
+ */
+ const ElementNode *findPrevSibilingElement(const char *pcszName, const char *pcszNamespace = NULL) const;
+
+ /** Find the next element matching the given name and namespace (optionally).
+ * @returns Pointer to the previous sibling element, NULL if first child
+ * element.
+ * @param pcszName The element name to match.
+ * @param pcszNamespace The namespace name, default is NULL which means
+ * anything goes.
+ * @note Changed the order of the arguments.
+ */
+ const ElementNode *findNextSibilingElement(const char *pcszName, const char *pcszNamespace = NULL) const;
+ /** @} */
+
+
+ const AttributeNode *findAttribute(const char *pcszMatch, const char *pcszNamespace = NULL) const;
+ /** Find the first attribute with the given name, returning its value string.
+ * @returns Pointer to the attribute string value.
+ * @param pcszName The attribute name.
+ * @param pcszNamespace The namespace name, default is NULL which means
+ * anything goes.
+ * @see getAttributeValue
+ */
+ const char *findAttributeValue(const char *pcszName, const char *pcszNamespace = NULL) const
+ {
+ const AttributeNode *pAttr = findAttribute(pcszName, pcszNamespace);
+ if (pAttr)
+ return pAttr->getValue();
+ return NULL;
+ }
+
+ bool getAttributeValue(const char *pcszMatch, const char *&pcsz, const char *pcszNamespace = NULL) const
+ { return getAttributeValue(pcszMatch, &pcsz, pcszNamespace); }
+ bool getAttributeValue(const char *pcszMatch, RTCString &str, const char *pcszNamespace = NULL) const
+ { return getAttributeValue(pcszMatch, &str, pcszNamespace); }
+ bool getAttributeValuePath(const char *pcszMatch, RTCString &str, const char *pcszNamespace = NULL) const
+ { return getAttributeValue(pcszMatch, &str, pcszNamespace); }
+ bool getAttributeValue(const char *pcszMatch, int32_t &i, const char *pcszNamespace = NULL) const
+ { return getAttributeValue(pcszMatch, &i, pcszNamespace); }
+ bool getAttributeValue(const char *pcszMatch, uint32_t &i, const char *pcszNamespace = NULL) const
+ { return getAttributeValue(pcszMatch, &i, pcszNamespace); }
+ bool getAttributeValue(const char *pcszMatch, int64_t &i, const char *pcszNamespace = NULL) const
+ { return getAttributeValue(pcszMatch, &i, pcszNamespace); }
+ bool getAttributeValue(const char *pcszMatch, uint64_t &u, const char *pcszNamespace = NULL) const
+ { return getAttributeValue(pcszMatch, &u, pcszNamespace); }
+ bool getAttributeValue(const char *pcszMatch, bool &f, const char *pcszNamespace = NULL) const
+ { return getAttributeValue(pcszMatch, &f, pcszNamespace); }
+
+ /** @name Variants that for clarity does not use references for output params.
+ * @{ */
+ bool getAttributeValue(const char *pcszMatch, const char **ppcsz, const char *pcszNamespace = NULL) const;
+ bool getAttributeValue(const char *pcszMatch, RTCString *pStr, const char *pcszNamespace = NULL) const;
+ bool getAttributeValuePath(const char *pcszMatch, RTCString *pStr, const char *pcszNamespace = NULL) const;
+ bool getAttributeValue(const char *pcszMatch, int32_t *pi, const char *pcszNamespace = NULL) const;
+ bool getAttributeValue(const char *pcszMatch, uint32_t *pu, const char *pcszNamespace = NULL) const;
+ bool getAttributeValue(const char *pcszMatch, int64_t *piValue, const char *pcszNamespace = NULL) const;
+ bool getAttributeValue(const char *pcszMatch, uint64_t *pu, const char *pcszNamespace = NULL) const;
+ bool getAttributeValue(const char *pcszMatch, bool *pf, const char *pcszNamespace = NULL) const;
+ /** @} */
+
+ /** @name Convenience methods for convering the element value.
+ * @{ */
+ bool getElementValue(int32_t *piValue) const;
+ bool getElementValue(uint32_t *puValue) const;
+ bool getElementValue(int64_t *piValue) const;
+ bool getElementValue(uint64_t *puValue) const;
+ bool getElementValue(bool *pfValue) const;
+ /** @} */
+
+ /** @name Convenience findChildElementAttributeValueP and getElementValue.
+ * @{ */
+ bool getChildElementValueP(const char *pcszPath, int32_t *piValue, const char *pcszNamespace = NULL) const
+ {
+ const ElementNode *pElem = findChildElementP(pcszPath, pcszNamespace);
+ return pElem && pElem->getElementValue(piValue);
+ }
+ bool getChildElementValueP(const char *pcszPath, uint32_t *puValue, const char *pcszNamespace = NULL) const
+ {
+ const ElementNode *pElem = findChildElementP(pcszPath, pcszNamespace);
+ return pElem && pElem->getElementValue(puValue);
+ }
+ bool getChildElementValueP(const char *pcszPath, int64_t *piValue, const char *pcszNamespace = NULL) const
+ {
+ const ElementNode *pElem = findChildElementP(pcszPath, pcszNamespace);
+ return pElem && pElem->getElementValue(piValue);
+ }
+ bool getChildElementValueP(const char *pcszPath, uint64_t *puValue, const char *pcszNamespace = NULL) const
+ {
+ const ElementNode *pElem = findChildElementP(pcszPath, pcszNamespace);
+ return pElem && pElem->getElementValue(puValue);
+ }
+ bool getChildElementValueP(const char *pcszPath, bool *pfValue, const char *pcszNamespace = NULL) const
+ {
+ const ElementNode *pElem = findChildElementP(pcszPath, pcszNamespace);
+ return pElem && pElem->getElementValue(pfValue);
+ }
+
+ /** @} */
+
+ /** @name Convenience findChildElementAttributeValueP and getElementValue with a
+ * default value being return if the child element isn't present.
+ *
+ * @remarks These will return false on conversion errors.
+ * @{ */
+ bool getChildElementValueDefP(const char *pcszPath, int32_t iDefault, int32_t *piValue, const char *pcszNamespace = NULL) const
+ {
+ const ElementNode *pElem = findChildElementP(pcszPath, pcszNamespace);
+ if (pElem)
+ return pElem->getElementValue(piValue);
+ *piValue = iDefault;
+ return true;
+ }
+ bool getChildElementValueDefP(const char *pcszPath, uint32_t uDefault, uint32_t *puValue, const char *pcszNamespace = NULL) const
+ {
+ const ElementNode *pElem = findChildElementP(pcszPath, pcszNamespace);
+ if (pElem)
+ return pElem->getElementValue(puValue);
+ *puValue = uDefault;
+ return true;
+ }
+ bool getChildElementValueDefP(const char *pcszPath, int64_t iDefault, int64_t *piValue, const char *pcszNamespace = NULL) const
+ {
+ const ElementNode *pElem = findChildElementP(pcszPath, pcszNamespace);
+ if (pElem)
+ return pElem->getElementValue(piValue);
+ *piValue = iDefault;
+ return true;
+ }
+ bool getChildElementValueDefP(const char *pcszPath, uint64_t uDefault, uint64_t *puValue, const char *pcszNamespace = NULL) const
+ {
+ const ElementNode *pElem = findChildElementP(pcszPath, pcszNamespace);
+ if (pElem)
+ return pElem->getElementValue(puValue);
+ *puValue = uDefault;
+ return true;
+ }
+ bool getChildElementValueDefP(const char *pcszPath, bool fDefault, bool *pfValue, const char *pcszNamespace = NULL) const
+ {
+ const ElementNode *pElem = findChildElementP(pcszPath, pcszNamespace);
+ if (pElem)
+ return pElem->getElementValue(pfValue);
+ *pfValue = fDefault;
+ return true;
+ }
+ /** @} */
+
+ ElementNode *createChild(const char *pcszElementName);
+
+ ContentNode *addContent(const char *pcszContent);
+ ContentNode *addContent(const RTCString &strContent)
{
return addContent(strContent.c_str());
}
- AttributeNode* setAttribute(const char *pcszName, const char *pcszValue);
- AttributeNode* setAttribute(const char *pcszName, const RTCString &strValue)
+ AttributeNode *setAttribute(const char *pcszName, const char *pcszValue);
+ AttributeNode *setAttribute(const char *pcszName, const RTCString &strValue)
{
return setAttribute(pcszName, strValue.c_str());
}
- AttributeNode* setAttributePath(const char *pcszName, const RTCString &strValue);
- AttributeNode* setAttribute(const char *pcszName, int32_t i);
- AttributeNode* setAttribute(const char *pcszName, uint32_t i);
- AttributeNode* setAttribute(const char *pcszName, int64_t i);
- AttributeNode* setAttribute(const char *pcszName, uint64_t i);
- AttributeNode* setAttributeHex(const char *pcszName, uint32_t i);
- AttributeNode* setAttribute(const char *pcszName, bool f);
+ AttributeNode *setAttributePath(const char *pcszName, const RTCString &strValue);
+ AttributeNode *setAttribute(const char *pcszName, int32_t i);
+ AttributeNode *setAttribute(const char *pcszName, uint32_t i);
+ AttributeNode *setAttribute(const char *pcszName, int64_t i);
+ AttributeNode *setAttribute(const char *pcszName, uint64_t i);
+ AttributeNode *setAttributeHex(const char *pcszName, uint32_t i);
+ AttributeNode *setAttribute(const char *pcszName, bool f);
+
+ virtual ~ElementNode();
protected:
// hide the default constructor so people use only our factory methods
- ElementNode(const ElementNode *pelmRoot, Node *pParent, xmlNode *plibNode);
+ ElementNode(const ElementNode *pElmRoot, Node *pParent, PRTLISTANCHOR pListAnchor, xmlNode *pLibNode);
ElementNode(const ElementNode &x); // no copying
- const ElementNode *m_pelmRoot;
+ /** We keep a pointer to the root element for attribute namespace handling. */
+ const ElementNode *m_pElmRoot;
+
+ /** List of child elements and content nodes. */
+ RTLISTANCHOR m_children;
+ /** List of attributes nodes. */
+ RTLISTANCHOR m_attributes;
+
+ static void buildChildren(ElementNode *pElmRoot);
friend class Node;
friend class Document;
@@ -519,41 +879,13 @@ public:
protected:
// hide the default constructor so people use only our factory methods
- ContentNode(Node *pParent, xmlNode *plibNode);
+ ContentNode(Node *pParent, PRTLISTANCHOR pListAnchor, xmlNode *pLibNode);
ContentNode(const ContentNode &x); // no copying
friend class Node;
friend class ElementNode;
};
-/**
- * Node subclass that represents an attribute of an element.
- *
- * For attributes, Node::getName() returns the attribute name, and Node::getValue()
- * returns the attribute value, if any.
- *
- * Since the Node constructor is private, one can create new attribute nodes
- * only through the following factory methods:
- *
- * -- ElementNode::setAttribute()
- */
-class RT_DECL_CLASS AttributeNode : public Node
-{
-public:
-
-protected:
- // hide the default constructor so people use only our factory methods
- AttributeNode(const ElementNode &elmRoot,
- Node *pParent,
- xmlAttr *plibAttr,
- const char **ppcszKey);
- AttributeNode(const AttributeNode &x); // no copying
-
- RTCString m_strKey;
-
- friend class Node;
- friend class ElementNode;
-};
/**
* Handy helper class with which one can loop through all or some children
@@ -583,7 +915,7 @@ private:
Document doc;
XmlFileParser parser;
parser.read("file.xml", doc);
- Element *pelmRoot = doc.getRootElement();
+ Element *pElmRoot = doc.getRootElement();
@endcode
*
* -- XmlMemWriter or XmlFileWriter to write out an XML document after it has
@@ -591,7 +923,7 @@ private:
*
* @code
Document doc;
- Element *pelmRoot = doc.createRootElement();
+ Element *pElmRoot = doc.createRootElement();
// add children
xml::XmlFileWriter writer(doc);
writer.write("file.xml", true);
diff --git a/include/iprt/crc.h b/include/iprt/crc.h
index 82e3b11b..0f9fa964 100644
--- a/include/iprt/crc.h
+++ b/include/iprt/crc.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2009 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/critsect.h b/include/iprt/critsect.h
index 41bb65bd..9dee8612 100644
--- a/include/iprt/critsect.h
+++ b/include/iprt/critsect.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2011 Oracle Corporation
+ * Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -109,6 +109,7 @@ AssertCompileSize(RTCRITSECT, HC_ARCH_BITS == 32 ? 32 : 48);
#define RTCRITSECT_FLAGS_NOP UINT32_C(0x00000008)
/** @} */
+
#ifdef IN_RING3
/**
@@ -120,18 +121,17 @@ RTDECL(int) RTCritSectInit(PRTCRITSECT pCritSect);
* Initialize a critical section.
*
* @returns iprt status code.
- * @param pCritSect Pointer to the critical section structure.
- * @param fFlags Flags, any combination of the RTCRITSECT_FLAGS
- * \#defines.
- * @param hClass The class (no reference consumed). If NIL, no
- * lock order validation will be performed on this
- * lock.
- * @param uSubClass The sub-class. This is used to define lock
- * order within a class. RTLOCKVAL_SUB_CLASS_NONE
- * is the recommended value here.
- * @param pszNameFmt Name format string for the lock validator,
- * optional (NULL). Max length is 32 bytes.
- * @param ... Format string arguments.
+ * @param pCritSect Pointer to the critical section structure.
+ * @param fFlags Flags, any combination of the RTCRITSECT_FLAGS
+ * \#defines.
+ * @param hClass The class (no reference consumed). If NIL, no lock
+ * order validation will be performed on this lock.
+ * @param uSubClass The sub-class. This is used to define lock order
+ * within a class. RTLOCKVAL_SUB_CLASS_NONE is the
+ * recommended value here.
+ * @param pszNameFmt Name format string for the lock validator, optional
+ * (NULL). Max length is 32 bytes.
+ * @param ... Format string arguments.
*/
RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags,
RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszNameFmt, ...);
@@ -145,8 +145,8 @@ RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags,
* @returns The old sub-class. RTLOCKVAL_SUB_CLASS_INVALID is returns if the
* lock validator isn't compiled in or either of the parameters are
* invalid.
- * @param pCritSect The critical section.
- * @param uSubClass The new sub-class value.
+ * @param pCritSect The critical section.
+ * @param uSubClass The new sub-class value.
*/
RTDECL(uint32_t) RTCritSectSetSubClass(PRTCRITSECT pCritSect, uint32_t uSubClass);
@@ -155,7 +155,8 @@ RTDECL(uint32_t) RTCritSectSetSubClass(PRTCRITSECT pCritSect, uint32_t uSubClass
*
* @returns VINF_SUCCESS on success.
* @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
- * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
* @param pCritSect The critical section.
*/
RTDECL(int) RTCritSectEnter(PRTCRITSECT pCritSect);
@@ -163,9 +164,11 @@ RTDECL(int) RTCritSectEnter(PRTCRITSECT pCritSect);
/**
* Enter a critical section.
*
+ * @returns IPRT status code.
* @retval VINF_SUCCESS on success.
* @retval VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
- * @retval VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
*
* @param pCritSect The critical section.
* @param uId Where we're entering the section.
@@ -181,7 +184,8 @@ RTDECL(int) RTCritSectEnterDebug(PRTCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_
* @retval VINF_SUCCESS on success.
* @retval VERR_SEM_BUSY if the critsect was owned.
* @retval VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
- * @retval VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
*
* @param pCritSect The critical section.
*/
@@ -193,7 +197,8 @@ RTDECL(int) RTCritSectTryEnter(PRTCRITSECT pCritSect);
* @retval VINF_SUCCESS on success.
* @retval VERR_SEM_BUSY if the critsect was owned.
* @retval VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
- * @retval VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
*
* @param pCritSect The critical section.
* @param uId Where we're entering the section.
@@ -210,7 +215,8 @@ RTDECL(int) RTCritSectTryEnterDebug(PRTCRITSECT pCritSect, RTHCUINTPTR uId, RT_S
*
* @returns VINF_SUCCESS on success.
* @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
- * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
* @param cCritSects Number of critical sections in the array.
* @param papCritSects Array of critical section pointers.
*
@@ -227,7 +233,8 @@ RTDECL(int) RTCritSectEnterMultiple(size_t cCritSects, PRTCRITSECT *papCritSects
*
* @returns VINF_SUCCESS on success.
* @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
- * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
*
* @param cCritSects Number of critical sections in the array.
* @param papCritSects Array of critical section pointers.
@@ -244,7 +251,7 @@ RTDECL(int) RTCritSectEnterMultipleDebug(size_t cCritSects, PRTCRITSECT *papCrit
* Leave a critical section.
*
* @returns VINF_SUCCESS.
- * @param pCritSect The critical section.
+ * @param pCritSect The critical section.
*/
RTDECL(int) RTCritSectLeave(PRTCRITSECT pCritSect);
@@ -261,7 +268,7 @@ RTDECL(int) RTCritSectLeaveMultiple(size_t cCritSects, PRTCRITSECT *papCritSects
* Deletes a critical section.
*
* @returns VINF_SUCCESS.
- * @param pCritSect The critical section.
+ * @param pCritSect The critical section.
*/
RTDECL(int) RTCritSectDelete(PRTCRITSECT pCritSect);
@@ -270,7 +277,7 @@ RTDECL(int) RTCritSectDelete(PRTCRITSECT pCritSect);
*
* @returns true if owner.
* @returns false if not owner.
- * @param pCritSect The critical section.
+ * @param pCritSect The critical section.
*/
DECLINLINE(bool) RTCritSectIsOwner(PCRTCRITSECT pCritSect)
{
@@ -284,7 +291,7 @@ DECLINLINE(bool) RTCritSectIsOwner(PCRTCRITSECT pCritSect)
*
* @returns true if owned.
* @returns false if not owned.
- * @param pCritSect The critical section.
+ * @param pCritSect The critical section.
*/
DECLINLINE(bool) RTCritSectIsOwned(PCRTCRITSECT pCritSect)
{
@@ -296,7 +303,7 @@ DECLINLINE(bool) RTCritSectIsOwned(PCRTCRITSECT pCritSect)
*
* @returns Thread id of the owner thread if owned.
* @returns NIL_RTNATIVETHREAD is not owned.
- * @param pCritSect The critical section.
+ * @param pCritSect The critical section.
*/
DECLINLINE(RTNATIVETHREAD) RTCritSectGetOwner(PCRTCRITSECT pCritSect)
{
@@ -308,7 +315,7 @@ DECLINLINE(RTNATIVETHREAD) RTCritSectGetOwner(PCRTCRITSECT pCritSect)
*
* @returns true if initialized.
* @returns false if not initialized.
- * @param pCritSect The critical section.
+ * @param pCritSect The critical section.
*/
DECLINLINE(bool) RTCritSectIsInitialized(PCRTCRITSECT pCritSect)
{
@@ -351,13 +358,385 @@ DECLINLINE(int32_t) RTCritSectGetWaiters(PCRTCRITSECT pCritSect)
#endif
/* Strict lock order: Automatically classify locks by init location. */
-#if defined(RT_LOCK_STRICT_ORDER) && defined(IN_RING3) && !defined(RTCRITSECT_WITHOUT_REMAPPING) &&!defined(RT_WITH_MANGLING)
+#if defined(RT_LOCK_STRICT_ORDER) && defined(IN_RING3) && !defined(RTCRITSECT_WITHOUT_REMAPPING) && !defined(RT_WITH_MANGLING)
# define RTCritSectInit(pCritSect) \
RTCritSectInitEx((pCritSect), 0 /*fFlags*/, \
RTLockValidatorClassForSrcPos(RT_SRC_POS, NULL), \
RTLOCKVAL_SUB_CLASS_NONE, NULL)
#endif
+/** @} */
+
+
+
+/** @defgroup grp_rt_critsectrw RTCritSectRw - Read/Write Critical Sections
+ * @ingroup grp_rt
+ * @{
+ */
+
+/**
+ * Read/write critical section.
+ */
+typedef struct RTCRITSECTRW
+{
+ /** Magic used to validate the section state.
+ * RTCRITSECTRW_MAGIC is the value of an initialized & operational section. */
+ volatile uint32_t u32Magic;
+
+ /** Indicates whether hEvtRead needs resetting. */
+ bool volatile fNeedReset;
+ /** Explicit alignment padding. */
+ bool volatile afPadding[1];
+ /** Section flags - the RTCRITSECT_FLAGS_* \#defines. */
+ uint16_t fFlags;
+
+ /** The state variable.
+ * All accesses are atomic and it bits are defined like this:
+ * Bits 0..14 - cReads.
+ * Bit 15 - Unused.
+ * Bits 16..31 - cWrites. - doesn't make sense here
+ * Bit 31 - fDirection; 0=Read, 1=Write.
+ * Bits 32..46 - cWaitingReads
+ * Bit 47 - Unused.
+ * Bits 48..62 - cWaitingWrites
+ * Bit 63 - Unused.
+ */
+ uint64_t volatile u64State;
+ /** The write owner. */
+ RTNATIVETHREAD volatile hNativeWriter;
+ /** The number of reads made by the current writer. */
+ uint32_t volatile cWriterReads;
+ /** The number of recursions made by the current writer. (The initial grabbing
+ * of the lock counts as the first one.) */
+ uint32_t volatile cWriteRecursions;
+
+ /** What the writer threads are blocking on. */
+ RTSEMEVENT hEvtWrite;
+ /** What the read threads are blocking on when waiting for the writer to
+ * finish. */
+ RTSEMEVENTMULTI hEvtRead;
+
+ /** The validator record for the writer. */
+ R3R0PTRTYPE(PRTLOCKVALRECEXCL) pValidatorWrite;
+ /** The validator record for the readers. */
+ R3R0PTRTYPE(PRTLOCKVALRECSHRD) pValidatorRead;
+#if HC_ARCH_BITS == 32
+ /** Size padding. */
+ RTHCPTR HCPtrPadding;
+#endif
+} RTCRITSECTRW;
+AssertCompileSize(RTCRITSECTRW, HC_ARCH_BITS == 32 ? 48 : 64);
+
+/** RTCRITSECTRW::u32Magic value. (Eric Allan Dolphy, Jr.) */
+#define RTCRITSECTRW_MAGIC UINT32_C(0x19280620)
+/** RTCRITSECTRW::u32Magic dead value. */
+#define RTCRITSECTRW_MAGIC_DEAD UINT32_C(0x19640629)
+
+/** @name RTCRITSECTRW::u64State values.
+ * @note Using RTCSRW instead of RTCRITSECTRW to save space.
+ * @{ */
+#define RTCSRW_CNT_BITS 15
+#define RTCSRW_CNT_MASK UINT64_C(0x00007fff)
+
+#define RTCSRW_CNT_RD_SHIFT 0
+#define RTCSRW_CNT_RD_MASK (RTCSRW_CNT_MASK << RTCSRW_CNT_RD_SHIFT)
+#define RTCSRW_CNT_WR_SHIFT 16
+#define RTCSRW_CNT_WR_MASK (RTCSRW_CNT_MASK << RTCSRW_CNT_WR_SHIFT)
+
+#define RTCSRW_DIR_SHIFT 31
+#define RTCSRW_DIR_MASK RT_BIT_64(RTCSRW_DIR_SHIFT)
+#define RTCSRW_DIR_READ UINT64_C(0)
+#define RTCSRW_DIR_WRITE UINT64_C(1)
+
+#define RTCSRW_WAIT_CNT_RD_SHIFT 32
+#define RTCSRW_WAIT_CNT_RD_MASK (RTCSRW_CNT_MASK << RTCSRW_WAIT_CNT_RD_SHIFT)
+/* #define RTCSRW_WAIT_CNT_WR_SHIFT 48 */
+/* #define RTCSRW_WAIT_CNT_WR_MASK (RTCSRW_CNT_MASK << RTCSRW_WAIT_CNT_WR_SHIFT) */
+/** @} */
+
+#ifdef IN_RING3
+
+/**
+ * Initialize a critical section.
+ */
+RTDECL(int) RTCritSectRwInit(PRTCRITSECTRW pThis);
+
+/**
+ * Initialize a critical section.
+ *
+ * @returns IPRT status code.
+ * @param pThis Pointer to the read/write critical section.
+ * @param fFlags Flags, any combination of the RTCRITSECT_FLAGS
+ * \#defines.
+ * @param hClass The class (no reference consumed). If NIL, no lock
+ * order validation will be performed on this lock.
+ * @param uSubClass The sub-class. This is used to define lock order
+ * within a class. RTLOCKVAL_SUB_CLASS_NONE is the
+ * recommended value here.
+ * @param pszNameFmt Name format string for the lock validator, optional
+ * (NULL). Max length is 32 bytes.
+ * @param ... Format string arguments.
+ */
+RTDECL(int) RTCritSectRwInitEx(PRTCRITSECTRW pThis, uint32_t fFlags,
+ RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszNameFmt, ...);
+
+/**
+ * Changes the lock validator sub-class of the critical section.
+ *
+ * It is recommended to try make sure that nobody is using this critical section
+ * while changing the value.
+ *
+ * @returns The old sub-class. RTLOCKVAL_SUB_CLASS_INVALID is returns if the
+ * lock validator isn't compiled in or either of the parameters are
+ * invalid.
+ * @param pThis Pointer to the read/write critical section.
+ * @param uSubClass The new sub-class value.
+ */
+RTDECL(uint32_t) RTCritSectRwSetSubClass(PRTCRITSECTRW pThis, uint32_t uSubClass);
+
+
+/**
+ * Enter a critical section with shared (read) access.
+ *
+ * @returns IPRT status code.
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
+ * @param pThis Pointer to the read/write critical section.
+ */
+RTDECL(int) RTCritSectRwEnterShared(PRTCRITSECTRW pThis);
+
+/**
+ * Enter a critical section with shared (read) access.
+ *
+ * @returns IPRT status code.
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
+ *
+ * @param pThis Pointer to the read/write critical section.
+ * @param uId Where we're entering the section.
+ * @param pszFile The source position - file.
+ * @param iLine The source position - line.
+ * @param pszFunction The source position - function.
+ */
+RTDECL(int) RTCritSectRwEnterSharedDebug(PRTCRITSECTRW pThis, RTHCUINTPTR uId, RT_SRC_POS_DECL);
+
+/**
+ * Try enter a critical section with shared (read) access.
+ *
+ * @returns IPRT status code.
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_SEM_BUSY if the critsect was owned.
+ * @retval VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
+ *
+ * @param pThis Pointer to the read/write critical section.
+ */
+RTDECL(int) RTCritSectRwTryEnterShared(PRTCRITSECTRW pThis);
+
+/**
+ * Try enter a critical section with shared (read) access.
+ *
+ * @returns IPRT status code.
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_SEM_BUSY if the critsect was owned.
+ * @retval VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
+ *
+ * @param pThis Pointer to the read/write critical section.
+ * @param uId Where we're entering the section.
+ * @param pszFile The source position - file.
+ * @param iLine The source position - line.
+ * @param pszFunction The source position - function.
+ */
+RTDECL(int) RTCritSectRwTryEnterSharedDebug(PRTCRITSECTRW pThis, RTHCUINTPTR uId, RT_SRC_POS_DECL);
+
+/**
+ * Leave a critical section held with shared access.
+ *
+ * @returns IPRT status code.
+ * @param pThis Pointer to the read/write critical section.
+ */
+RTDECL(int) RTCritSectRwLeaveShared(PRTCRITSECTRW pThis);
+
+
+/**
+ * Enter a critical section with exclusive (write) access.
+ *
+ * @returns IPRT status code.
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
+ * @param pThis Pointer to the read/write critical section.
+ */
+RTDECL(int) RTCritSectRwEnterExcl(PRTCRITSECTRW pThis);
+
+/**
+ * Enter a critical section with exclusive (write) access.
+ *
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
+ *
+ * @param pThis Pointer to the read/write critical section.
+ * @param uId Where we're entering the section.
+ * @param pszFile The source position - file.
+ * @param iLine The source position - line.
+ * @param pszFunction The source position - function.
+ */
+RTDECL(int) RTCritSectRwEnterExclDebug(PRTCRITSECTRW pThis, RTHCUINTPTR uId, RT_SRC_POS_DECL);
+
+/**
+ * Try enter a critical section with exclusive (write) access.
+ *
+ * @returns IPRT status code.
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_SEM_BUSY if the critsect was owned.
+ * @retval VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
+ *
+ * @param pThis Pointer to the read/write critical section.
+ */
+RTDECL(int) RTCritSectRwTryEnterExcl(PRTCRITSECTRW pThis);
+
+/**
+ * Try enter a critical section with exclusive (write) access.
+ *
+ * @returns IPRT status code.
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_SEM_BUSY if the critsect was owned.
+ * @retval VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
+ * @retval VERR_SEM_DESTROYED if the critical section is delete before or
+ * during the operation.
+ *
+ * @param pThis Pointer to the read/write critical section.
+ * @param uId Where we're entering the section.
+ * @param pszFile The source position - file.
+ * @param iLine The source position - line.
+ * @param pszFunction The source position - function.
+ */
+RTDECL(int) RTCritSectRwTryEnterExclDebug(PRTCRITSECTRW pThis, RTHCUINTPTR uId, RT_SRC_POS_DECL);
+
+/**
+ * Leave a critical section held exclusively.
+ *
+ * @returns IPRT status code; VINF_SUCCESS, VERR_NOT_OWNER, VERR_SEM_DESTROYED,
+ * or VERR_WRONG_ORDER.
+ * @param pThis Pointer to the read/write critical section.
+ */
+RTDECL(int) RTCritSectRwLeaveExcl(PRTCRITSECTRW pThis);
+
+
+/**
+ * Deletes a critical section.
+ *
+ * @returns VINF_SUCCESS.
+ * @param pThis Pointer to the read/write critical section.
+ */
+RTDECL(int) RTCritSectRwDelete(PRTCRITSECTRW pThis);
+
+/**
+ * Checks the caller is the exclusive (write) owner of the critical section.
+ *
+ * @retval @c true if owner.
+ * @retval @c false if not owner.
+ * @param pThis Pointer to the read/write critical section.
+ */
+RTDECL(bool) RTCritSectRwIsWriteOwner(PRTCRITSECTRW pThis);
+
+/**
+ * Checks if the caller is one of the read owners of the critical section.
+ *
+ * @note !CAUTION! This API doesn't work reliably if lock validation isn't
+ * enabled. Meaning, the answer is not trustworhty unless
+ * RT_LOCK_STRICT or RTCRITSECTRW_STRICT was defined at build time.
+ * Also, make sure you do not use RTCRITSECTRW_FLAGS_NO_LOCK_VAL when
+ * creating the semaphore. And finally, if you used a locking class,
+ * don't disable deadlock detection by setting cMsMinDeadlock to
+ * RT_INDEFINITE_WAIT.
+ *
+ * In short, only use this for assertions.
+ *
+ * @returns @c true if reader, @c false if not.
+ * @param pThis Pointer to the read/write critical section.
+ * @param fWannaHear What you'd like to hear when lock validation is not
+ * available. (For avoiding asserting all over the
+ * place.)
+ */
+RTDECL(bool) RTCritSectRwIsReadOwner(PRTCRITSECTRW pThis, bool fWannaHear);
+
+/**
+ * Gets the write recursion count.
+ *
+ * @returns The write recursion count (0 if bad critsect).
+ * @param pThis Pointer to the read/write critical section.
+ */
+RTDECL(uint32_t) RTCritSectRwGetWriteRecursion(PRTCRITSECTRW pThis);
+
+/**
+ * Gets the read recursion count of the current writer.
+ *
+ * @returns The read recursion count (0 if bad critsect).
+ * @param pThis Pointer to the read/write critical section.
+ */
+RTDECL(uint32_t) RTCritSectRwGetWriterReadRecursion(PRTCRITSECTRW pThis);
+
+/**
+ * Gets the current number of reads.
+ *
+ * This includes all read recursions, so it might be higher than the number of
+ * read owners. It does not include reads done by the current writer.
+ *
+ * @returns The read count (0 if bad critsect).
+ * @param pThis Pointer to the read/write critical section.
+ */
+RTDECL(uint32_t) RTCritSectRwGetReadCount(PRTCRITSECTRW pThis);
+
+#endif /* IN_RING3 */
+
+/**
+ * Checks if a critical section is initialized or not.
+ *
+ * @retval @c true if initialized.
+ * @retval @c false if not initialized.
+ * @param pThis Pointer to the read/write critical section.
+ */
+DECLINLINE(bool) RTCritSectRwIsInitialized(PCRTCRITSECTRW pThis)
+{
+ return pThis->u32Magic == RTCRITSECTRW_MAGIC;
+}
+
+/* Lock strict build: Remap the three enter calls to the debug versions. */
+#if defined(RT_LOCK_STRICT) && !defined(RTCRITSECTRW_WITHOUT_REMAPPING) && !defined(RT_WITH_MANGLING)
+# ifdef ___iprt_asm_h
+# define RTCritSectRwEnterExcl(pThis) RTCritSectRwEnterExclDebug(pThis, (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
+# define RTCritSectRwTryEnterExcl(pThis) RTCritSectRwTryEnterExclDebug(pThis, (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
+# define RTCritSectRwEnterShared(pThis) RTCritSectRwEnterSharedDebug(pThis, (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
+# define RTCritSectRwTryEnterShared(pThis) RTCritSectRwTryEnterSharedDebug(pThis, (uintptr_t)ASMReturnAddress(), RT_SRC_POS)
+# else
+# define RTCritSectRwEnterExcl(pThis) RTCritSectRwEnterExclDebug(pThis, 0, RT_SRC_POS)
+# define RTCritSectRwTryEnterExcl(pThis) RTCritSectRwTryEnterExclDebug(pThis, 0, RT_SRC_POS)
+# define RTCritSectRwEnterShared(pThis) RTCritSectRwEnterSharedDebug(pThis, 0, RT_SRC_POS)
+# define RTCritSectRwTryEnterShared(pThis) RTCritSectRwTryEnterSharedDebug(pThis, 0, RT_SRC_POS)
+# endif
+#endif
+
+/* Strict lock order: Automatically classify locks by init location. */
+#if defined(RT_LOCK_STRICT_ORDER) && defined(IN_RING3) && !defined(RTCRITSECTRW_WITHOUT_REMAPPING) && !defined(RT_WITH_MANGLING)
+# define RTCritSectRwInit(a_pThis) \
+ RTCritSectRwInitEx((a_pThis), 0 /*fFlags*/, \
+ RTLockValidatorClassForSrcPos(RT_SRC_POS, NULL), \
+ RTLOCKVAL_SUB_CLASS_NONE, NULL)
+#endif
+
/** @} */
RT_C_DECLS_END
diff --git a/include/iprt/ctype.h b/include/iprt/ctype.h
index b491aa32..e97b00d7 100644
--- a/include/iprt/ctype.h
+++ b/include/iprt/ctype.h
@@ -3,7 +3,7 @@
*/
/*
- * 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;
diff --git a/include/iprt/dbg.h b/include/iprt/dbg.h
index 04bea827..4a384a05 100644
--- a/include/iprt/dbg.h
+++ b/include/iprt/dbg.h
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008-2009 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -29,6 +29,7 @@
#include <iprt/types.h>
#include <iprt/stdarg.h>
+#include <iprt/ldr.h>
RT_C_DECLS_BEGIN
@@ -61,6 +62,7 @@ typedef RTDBGSEGIDX const *PCRTDBGSEGIDX;
#define RTDBGSEGIDX_SPECIAL_FIRST (RTDBGSEGIDX_LAST + 1U)
+
/** @name RTDBGSYMADDR_FLAGS_XXX
* Flags used when looking up a symbol by address.
* @{ */
@@ -212,6 +214,258 @@ RTDECL(PRTDBGLINE) RTDbgLineDup(PCRTDBGLINE pLine);
RTDECL(void) RTDbgLineFree(PRTDBGLINE pLine);
+/** @defgroup grp_rt_dbgcfg RTDbgCfg - Debugging Configuration
+ *
+ * The settings used when loading and processing debug info is kept in a
+ * RTDBGCFG instance since it's generally shared for a whole debugging session
+ * and anyhow would be a major pain to pass as individual parameters to each
+ * call. The debugging config API not only keeps the settings information but
+ * also provide APIs for making use of it, and in some cases, like for instance
+ * symbol severs, retriving and maintaining it.
+ *
+ * @todo Work in progress - APIs are still missing, adding when needed.
+ *
+ * @{
+ */
+
+/** Debugging configuration handle. */
+typedef struct RTDBGCFGINT *RTDBGCFG;
+/** Pointer to a debugging configuration handle. */
+typedef RTDBGCFG *PRTDBGCFG;
+/** NIL debug configuration handle. */
+#define NIL_RTDBGCFG ((RTDBGCFG)0)
+
+/** @name RTDBGCFG_FLAGS_XXX - Debugging configuration flags.
+ * @{ */
+/** Use deferred loading. */
+#define RTDBGCFG_FLAGS_DEFERRED RT_BIT_64(0)
+/** Don't use the symbol server (http). */
+#define RTDBGCFG_FLAGS_NO_SYM_SRV RT_BIT_64(1)
+/** Don't use system search paths.
+ * On windows this means not using _NT_ALT_SYMBOL_PATH, _NT_SYMBOL_PATH,
+ * _NT_SOURCE_PATH, and _NT_EXECUTABLE_PATH.
+ * On other systems the effect has yet to be determined. */
+#define RTDBGCFG_FLAGS_NO_SYSTEM_PATHS RT_BIT_64(2)
+/** Don't search the debug and image paths recursively. */
+#define RTDBGCFG_FLAGS_NO_RECURSIV_SEARCH RT_BIT_64(3)
+/** Don't search the source paths recursively. */
+#define RTDBGCFG_FLAGS_NO_RECURSIV_SRC_SEARCH RT_BIT_64(4)
+/** @} */
+
+/**
+ * Debugging configuration properties.
+ *
+ * The search paths are using the DOS convention of semicolon as separator
+ * character. The the special 'srv' + asterisk syntax known from the windows
+ * debugger search paths are also supported to some extent, as is 'cache' +
+ * asterisk.
+ */
+typedef enum RTDBGCFGPROP
+{
+ /** The customary invalid 0 value. */
+ RTDBGCFGPROP_INVALID = 0,
+ /** RTDBGCFG_FLAGS_XXX.
+ * Env: _FLAGS
+ * The environment variable can be specified as a unsigned value or one or more
+ * mnemonics separated by spaces. */
+ RTDBGCFGPROP_FLAGS,
+ /** List of paths to search for symbol files and images.
+ * Env: _PATH */
+ RTDBGCFGPROP_PATH,
+ /** List of symbol file suffixes (semicolon separated).
+ * Env: _SUFFIXES */
+ RTDBGCFGPROP_SUFFIXES,
+ /** List of paths to search for source files.
+ * Env: _SRC_PATH */
+ RTDBGCFGPROP_SRC_PATH,
+ /** End of valid values. */
+ RTDBGCFGPROP_END,
+ /** The customary 32-bit type hack. */
+ RTDBGCFGPROP_32BIT_HACK = 0x7fffffff
+} RTDBGCFGPROP;
+
+/**
+ * Configuration property change operation.
+ */
+typedef enum RTDBGCFGOP
+{
+ /** Customary invalid 0 value. */
+ RTDBGCFGOP_INVALID = 0,
+ /** Replace the current value with the given one. */
+ RTDBGCFGOP_SET,
+ /** Append the given value to the existing one. For integer values this is
+ * considered a bitwise OR operation. */
+ RTDBGCFGOP_APPEND,
+ /** Prepend the given value to the existing one. For integer values this is
+ * considered a bitwise OR operation. */
+ RTDBGCFGOP_PREPEND,
+ /** Removes the value from the existing one. For interger values the value is
+ * complemented and ANDed with the existing one, clearing all the specified
+ * flags/bits. */
+ RTDBGCFGOP_REMOVE,
+ /** End of valid values. */
+ RTDBGCFGOP_END,
+ /** Customary 32-bit type hack. */
+ RTDBGCFGOP_32BIT_HACK = 0x7fffffff
+} RTDBGCFGOP;
+
+
+
+/**
+ * Initializes a debugging configuration.
+ *
+ * @returns IPRT status code.
+ * @param phDbgCfg Where to return the configuration handle.
+ * @param pszEnvVarPrefix The environment variable prefix. If NULL, the
+ * environment is not consulted.
+ * @param fNativePaths Whether to pick up native paths from the
+ * environment.
+ *
+ * @sa RTDbgCfgChangeString, RTDbgCfgChangeUInt.
+ */
+RTDECL(int) RTDbgCfgCreate(PRTDBGCFG phDbgCfg, const char *pszEnvVarPrefix, bool fNativePaths);
+
+/**
+ * Retains a new reference to a debugging config.
+ *
+ * @returns New reference count.
+ * UINT32_MAX is returned if the handle is invalid (asserted).
+ * @param hDbgCfg The config handle.
+ */
+RTDECL(uint32_t) RTDbgCfgRetain(RTDBGCFG hDbgCfg);
+
+/**
+ * Releases a references to a debugging config.
+ *
+ * @returns New reference count, if 0 the config was freed. UINT32_MAX is
+ * returned if the handle is invalid (asserted).
+ * @param hDbgCfg The config handle.
+ */
+RTDECL(uint32_t) RTDbgCfgRelease(RTDBGCFG hDbgCfg);
+
+/**
+ * Changes a property value by string.
+ *
+ * For string values the string is used more or less as given. For integer
+ * values and flags, it can contains both values (ORed together) or property
+ * specific mnemonics (ORed / ~ANDed).
+ *
+ * @returns IPRT status code.
+ * @retval VERR_DBG_CFG_INVALID_VALUE
+ * @param hDbgCfg The debugging configuration handle.
+ * @param enmProp The property to change.
+ * @param enmOp How to change the property.
+ * @param pszValue The property value to apply.
+ */
+RTDECL(int) RTDbgCfgChangeString(RTDBGCFG hDbgCfg, RTDBGCFGPROP enmProp, RTDBGCFGOP enmOp, const char *pszValue);
+
+/**
+ * Changes a property value by unsigned integer (64-bit).
+ *
+ * This can only be applied to integer and flag properties.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_DBG_CFG_NOT_UINT_PROP
+ * @param hDbgCfg The debugging configuration handle.
+ * @param enmProp The property to change.
+ * @param enmOp How to change the property.
+ * @param uValue The property value to apply.
+ */
+RTDECL(int) RTDbgCfgChangeUInt(RTDBGCFG hDbgCfg, RTDBGCFGPROP enmProp, RTDBGCFGOP enmOp, uint64_t uValue);
+
+/**
+ * Query a property value as string.
+ *
+ * Integer and flags properties are returned as a list of mnemonics if possible,
+ * otherwise as simple hex values.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_BUFFER_OVERFLOW if there isn't sufficient buffer space. Nothing
+ * is written.
+ * @param hDbgCfg The debugging configuration handle.
+ * @param enmProp The property to change.
+ * @param pszValue The output buffer.
+ * @param cbValue The size of the output buffer.
+ */
+RTDECL(int) RTDbgCfgQueryString(RTDBGCFG hDbgCfg, RTDBGCFGPROP enmProp, char *pszValue, size_t cbValue);
+
+/**
+ * Query a property value as unsigned integer (64-bit).
+ *
+ * Only integer and flags properties can be queried this way.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_DBG_CFG_NOT_UINT_PROP
+ * @param hDbgCfg The debugging configuration handle.
+ * @param enmProp The property to change.
+ * @param puValue Where to return the value.
+ */
+RTDECL(int) RTDbgCfgQueryUInt(RTDBGCFG hDbgCfg, RTDBGCFGPROP enmProp, uint64_t *puValue);
+
+/**
+ * Log callback.
+ *
+ * @param hDbgCfg The debug config instance.
+ * @param iLevel The message level.
+ * @param pszMsg The message.
+ * @param pvUser User argument.
+ */
+typedef DECLCALLBACK(void) FNRTDBGCFGLOG(RTDBGCFG hDbgCfg, uint32_t iLevel, const char *pszMsg, void *pvUser);
+/** Pointer to a log callback. */
+typedef FNRTDBGCFGLOG *PFNRTDBGCFGLOG;
+
+/**
+ * Sets the log callback for the configuration.
+ *
+ * This will fail if there is already a log callback present, unless pfnCallback
+ * is NULL.
+ *
+ * @returns IPRT status code.
+ * @param hDbgCfg The debugging configuration handle.
+ * @param pfnCallback The callback function. NULL to unset.
+ * @param pvUser The user argument.
+ */
+RTDECL(int) RTDbgCfgSetLogCallback(RTDBGCFG hDbgCfg, PFNRTDBGCFGLOG pfnCallback, void *pvUser);
+
+/**
+ * Callback used by the RTDbgCfgOpen function to try out a file that was found.
+ *
+ * @returns On statuses other than VINF_CALLBACK_RETURN and
+ * VERR_CALLBACK_RETURN the search will continue till the end of the
+ * list. These status codes will not necessarily be propagated to the
+ * caller in any consistent manner.
+ * @retval VINF_CALLBACK_RETURN if successuflly opened the file and it's time
+ * to return
+ * @retval VERR_CALLBACK_RETURN if we shouldn't stop searching.
+ *
+ * @param hDbgCfg The debugging configuration handle.
+ * @param pszFilename The path to the file that should be tried out.
+ * @param pvUser1 First user parameter.
+ * @param pvUser2 Second user parameter.
+ */
+typedef DECLCALLBACK(int) FNDBGCFGOPEN(RTDBGCFG hDbgCfg, const char *pszFilename, void *pvUser1, void *pvUser2);
+/** Pointer to a open-file callback used to the RTDbgCfgOpen functions. */
+typedef FNDBGCFGOPEN *PFNDBGCFGOPEN;
+
+
+RTDECL(int) RTDbgCfgOpenPeImage(RTDBGCFG hDbgCfg, const char *pszFilename, uint32_t cbImage, uint32_t uTimestamp,
+ PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
+RTDECL(int) RTDbgCfgOpenPdb70(RTDBGCFG hDbgCfg, const char *pszFilename, PCRTUUID pUuid, uint32_t uAge,
+ PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
+RTDECL(int) RTDbgCfgOpenPdb20(RTDBGCFG hDbgCfg, const char *pszFilename, uint32_t cbImage, uint32_t uTimestamp, uint32_t uAge,
+ PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
+RTDECL(int) RTDbgCfgOpenDbg(RTDBGCFG hDbgCfg, const char *pszFilename, uint32_t cbImage, uint32_t uTimestamp,
+ PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
+RTDECL(int) RTDbgCfgOpenDwo(RTDBGCFG hDbgCfg, const char *pszFilename, uint32_t uCrc32,
+ PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
+
+RTDECL(int) RTDbgCfgOpenDsymBundle(RTDBGCFG hDbgCfg, const char *pszFilename, PCRTUUID pUuid,
+ PFNDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2);
+
+
+/** @} */
+
+
/** @defgroup grp_rt_dbgas RTDbgAs - Debug Address Space
* @{
*/
@@ -283,6 +537,22 @@ RTDECL(uint32_t) RTDbgAsRetain(RTDBGAS hDbgAs);
RTDECL(uint32_t) RTDbgAsRelease(RTDBGAS hDbgAs);
/**
+ * Locks the address space for exclusive access.
+ *
+ * @returns IRPT status code
+ * @param hDbgAs The address space handle.
+ */
+RTDECL(int) RTDbgAsLockExcl(RTDBGAS hDbgAs);
+
+/**
+ * Counters the actions of one RTDbgAsUnlockExcl call.
+ *
+ * @returns IRPT status code
+ * @param hDbgAs The address space handle.
+ */
+RTDECL(int) RTDbgAsUnlockExcl(RTDBGAS hDbgAs);
+
+/**
* Gets the name of an address space.
*
* @returns read only address space name.
@@ -580,24 +850,9 @@ RTDECL(int) RTDbgAsSymbolByName(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYM
RTDECL(int) RTDbgAsSymbolByNameA(RTDBGAS hDbgAs, const char *pszSymbol, PRTDBGSYMBOL *ppSymbol, PRTDBGMOD phMod);
/**
- * Query a line number by address.
- *
- * @returns IPRT status code. See RTDbgModSymbolAddrA for more specific ones.
- * @retval VERR_INVALID_HANDLE if hDbgAs is invalid.
- * @retval VERR_NOT_FOUND if the address couldn't be mapped to a module.
- *
- * @param hDbgAs The address space handle.
- * @param Addr The address which closest symbol is requested.
- * @param poffDisp Where to return the distance between the line
- * number and address.
- * @param pLine Where to return the line number information.
- */
-RTDECL(int) RTDbgAs(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE pLine);
-
-/**
* Adds a line number to a module in the address space.
*
- * @returns IPRT status code. See RTDbgModSymbolAdd for more specific ones.
+ * @returns IPRT status code. See RTDbgModLineAdd for more specific ones.
* @retval VERR_INVALID_HANDLE if hDbgAs is invalid.
* @retval VERR_NOT_FOUND if no module was found at the specified address.
* @retval VERR_NOT_SUPPORTED if the module interpret doesn't support adding
@@ -613,11 +868,10 @@ RTDECL(int) RTDbgAs(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLI
*/
RTDECL(int) RTDbgAsLineAdd(RTDBGAS hDbgAs, const char *pszFile, uint32_t uLineNo, RTUINTPTR Addr, uint32_t *piOrdinal);
-
/**
* Query a line number by address.
*
- * @returns IPRT status code. See RTDbgModSymbolAddrA for more specific ones.
+ * @returns IPRT status code. See RTDbgModLineAddrA for more specific ones.
* @retval VERR_INVALID_HANDLE if hDbgAs is invalid.
* @retval VERR_NOT_FOUND if the address couldn't be mapped to a module.
*
@@ -626,13 +880,14 @@ RTDECL(int) RTDbgAsLineAdd(RTDBGAS hDbgAs, const char *pszFile, uint32_t uLineNo
* @param poffDisp Where to return the distance between the line
* number and address.
* @param pLine Where to return the line number information.
+ * @param phMod Where to return the module handle. Optional.
*/
-RTDECL(int) RTDbgAsLineByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE pLine);
+RTDECL(int) RTDbgAsLineByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod);
/**
* Query a line number by address.
*
- * @returns IPRT status code. See RTDbgModSymbolAddrA for more specific ones.
+ * @returns IPRT status code. See RTDbgModLineAddrA for more specific ones.
* @retval VERR_INVALID_HANDLE if hDbgAs is invalid.
* @retval VERR_NOT_FOUND if the address couldn't be mapped to a module.
*
@@ -642,8 +897,9 @@ RTDECL(int) RTDbgAsLineByAddr(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp
* number and address.
* @param ppLine Where to return the pointer to the allocated line
* number info. Always set. Free with RTDbgLineFree.
+ * @param phMod Where to return the module handle. Optional.
*/
-RTDECL(int) RTDbgAsLineByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE *ppLine);
+RTDECL(int) RTDbgAsLineByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDisp, PRTDBGLINE *ppLine, PRTDBGMOD phMod);
/** @todo Missing some bits here. */
@@ -672,9 +928,18 @@ RTDECL(int) RTDbgAsLineByAddrA(RTDBGAS hDbgAs, RTUINTPTR Addr, PRTINTPTR poffDis
*/
RTDECL(int) RTDbgModCreate(PRTDBGMOD phDbgMod, const char *pszName, RTUINTPTR cbSeg, uint32_t fFlags);
-RTDECL(int) RTDbgModCreateDeferred(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, RTUINTPTR cb, uint32_t fFlags);
-RTDECL(int) RTDbgModCreateFromImage(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, uint32_t fFlags);
-RTDECL(int) RTDbgModCreateFromMap(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, RTUINTPTR uSubtrahend, uint32_t fFlags);
+RTDECL(int) RTDbgModCreateFromImage(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName,
+ RTLDRARCH enmArch, RTDBGCFG hDbgCfg);
+RTDECL(int) RTDbgModCreateFromMap(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, RTUINTPTR uSubtrahend,
+ RTDBGCFG hDbgCfg);
+RTDECL(int) RTDbgModCreateFromPeImage(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, RTLDRMOD hLdrMod,
+ uint32_t cbImage, uint32_t uTimeDateStamp, RTDBGCFG hDbgCfg);
+RTDECL(int) RTDbgModCreateFromDbg(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, uint32_t cbImage,
+ uint32_t uTimeDateStamp, RTDBGCFG hDbgCfg);
+RTDECL(int) RTDbgModCreateFromPdb(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, uint32_t cbImage,
+ PCRTUUID pUuid, uint32_t Age, RTDBGCFG hDbgCfg);
+RTDECL(int) RTDbgModCreateFromDwo(PRTDBGMOD phDbgMod, const char *pszFilename, const char *pszName, uint32_t cbImage,
+ uint32_t uCrc32, RTDBGCFG hDbgCfg);
/**
@@ -703,6 +968,18 @@ RTDECL(uint32_t) RTDbgModRetain(RTDBGMOD hDbgMod);
RTDECL(uint32_t) RTDbgModRelease(RTDBGMOD hDbgMod);
/**
+ * Removes all content from the debug module (container), optionally only
+ * leaving segments and image size intact.
+ *
+ * This is only possible on container modules, i.e. created by RTDbgModCreate().
+ *
+ * @returns IPRT status code.
+ * @param hDbgMod The module handle.
+ * @param fLeaveSegments Whether to leave segments (and image size) as is.
+ */
+RTDECL(int) RTDbgModRemoveAll(RTDBGMOD hDbgMod, bool fLeaveSegments);
+
+/**
* Gets the module name.
*
* @returns Pointer to a read only string containing the name.
@@ -712,6 +989,51 @@ RTDECL(uint32_t) RTDbgModRelease(RTDBGMOD hDbgMod);
RTDECL(const char *) RTDbgModName(RTDBGMOD hDbgMod);
/**
+ * Gets the name of the debug info file we're using.
+ *
+ * @returns Pointer to a read only string containing the filename, NULL if we
+ * don't use one.
+ *
+ * @param hDbgMod The module handle.
+ */
+RTDECL(const char *) RTDbgModDebugFile(RTDBGMOD hDbgMod);
+
+/**
+ * Gets the image filename (as specified by the user).
+ *
+ * @returns Pointer to a read only string containing the filename.
+ *
+ * @param hDbgMod The module handle.
+ */
+RTDECL(const char *) RTDbgModImageFile(RTDBGMOD hDbgMod);
+
+/**
+ * Gets the image filename actually used if it differs from RTDbgModImageFile.
+ *
+ * @returns Pointer to a read only string containing the filename, NULL if same
+ * as RTDBgModImageFile.
+ *
+ * @param hDbgMod The module handle.
+ */
+RTDECL(const char *) RTDbgModImageFileUsed(RTDBGMOD hDbgMod);
+
+/**
+ * Checks if the loading of the debug info has been postponed.
+ *
+ * @returns true if postponed, false if not or invalid handle.
+ * @param hDbgMod The module handle.
+ */
+RTDECL(bool) RTDbgModIsDeferred(RTDBGMOD hDbgMod);
+
+/**
+ * Checks if the debug info is exports only.
+ *
+ * @returns true if exports only, false if not or invalid handle.
+ * @param hDbgMod The module handle.
+ */
+RTDECL(bool) RTDbgModIsExports(RTDBGMOD hDbgMod);
+
+/**
* Converts an image relative address to a segment:offset address.
*
* @returns Segment index on success.
diff --git a/include/iprt/dir.h b/include/iprt/dir.h
index 38d99aa3..54e23594 100644
--- a/include/iprt/dir.h
+++ b/include/iprt/dir.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -272,8 +272,8 @@ typedef struct RTDIRENTRY
* RTDIRENTRYTYPE_UNKNOWN is a common return value here since not all file
* systems (or Unixes) stores the type of a directory entry and instead
* expects the user to use stat() to get it. So, when you see this you
- * should use RTPathQueryInfo to get the type, or if if you're lazy, use
- * RTDirReadEx. */
+ * should use RTDirQueryUnknownType or RTDirQueryUnknownTypeEx to get the type,
+ * or if if you're lazy, use RTDirReadEx. */
RTDIRENTRYTYPE enmType;
/** The length of the filename, excluding the terminating nul character. */
uint16_t cbName;
@@ -284,6 +284,8 @@ typedef struct RTDIRENTRY
#pragma pack()
/** Pointer to a directory entry. */
typedef RTDIRENTRY *PRTDIRENTRY;
+/** Pointer to a const directory entry. */
+typedef RTDIRENTRY const *PCRTDIRENTRY;
/**
@@ -313,6 +315,8 @@ typedef struct RTDIRENTRYEX
#pragma pack()
/** Pointer to a directory entry. */
typedef RTDIRENTRYEX *PRTDIRENTRYEX;
+/** Pointer to a const directory entry. */
+typedef RTDIRENTRYEX const *PCRTDIRENTRYEX;
/**
@@ -409,6 +413,55 @@ RTDECL(int) RTDirRead(PRTDIR pDir, PRTDIRENTRY pDirEntry, size_t *pcbDirEntry);
*/
RTDECL(int) RTDirReadEx(PRTDIR pDir, PRTDIRENTRYEX pDirEntry, size_t *pcbDirEntry, RTFSOBJATTRADD enmAdditionalAttribs, uint32_t fFlags);
+/**
+ * Resolves RTDIRENTRYTYPE_UNKNOWN values returned by RTDirRead.
+ *
+ * @returns IPRT status code (see RTPathQueryInfo).
+ * @param pszComposedName The path to the directory entry. The caller must
+ * compose this, it's NOT sufficient to pass
+ * RTDIRENTRY::szName!
+ * @param fFollowSymlinks Whether to follow symbolic links or not.
+ * @param penmType Pointer to the RTDIRENTRY::enmType member. If this
+ * is not RTDIRENTRYTYPE_UNKNOWN and, if
+ * @a fFollowSymlinks is false, not
+ * RTDIRENTRYTYPE_SYMLINK, the function will return
+ * immediately without doing anything. Otherwise it
+ * will use RTPathQueryInfo to try figure out the
+ * correct value. On failure, this will be unchanged.
+ */
+RTDECL(int) RTDirQueryUnknownType(const char *pszComposedName, bool fFollowSymlinks, RTDIRENTRYTYPE *penmType);
+
+/**
+ * Resolves RTDIRENTRYTYPE_UNKNOWN values returned by RTDirRead, extended
+ * version.
+ *
+ * @returns IPRT status code (see RTPathQueryInfo).
+ * @param pszComposedName The path to the directory entry. The caller must
+ * compose this, it's NOT sufficient to pass
+ * RTDIRENTRY::szName!
+ * @param fFollowSymlinks Whether to follow symbolic links or not.
+ * @param penmType Pointer to the RTDIRENTRY::enmType member or
+ * similar. Will NOT be checked on input.
+ * @param pObjInfo The object info buffer to use with RTPathQueryInfo.
+ */
+RTDECL(int) RTDirQueryUnknownTypeEx(const char *pszComposedName, bool fFollowSymlinks, RTDIRENTRYTYPE *penmType, PRTFSOBJINFO pObjInfo);
+
+/**
+ * Checks if the directory entry returned by RTDirRead is '.', '..' or similar.
+ *
+ * @returns true / false.
+ * @param pDirEntry The directory entry to check.
+ */
+RTDECL(bool) RTDirEntryIsStdDotLink(PRTDIRENTRY pDirEntry);
+
+/**
+ * Checks if the directory entry returned by RTDirReadEx is '.', '..' or
+ * similar.
+ *
+ * @returns true / false.
+ * @param pDirEntryEx The extended directory entry to check.
+ */
+RTDECL(bool) RTDirEntryExIsStdDotLink(PCRTDIRENTRYEX pDirEntryEx);
/**
* Renames a file.
diff --git a/include/iprt/dvm.h b/include/iprt/dvm.h
index f36a5f10..4501856e 100644
--- a/include/iprt/dvm.h
+++ b/include/iprt/dvm.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2011 Oracle Corporation
+ * Copyright (C) 2011-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/include/iprt/env.h b/include/iprt/env.h
index 64277d12..d956a06e 100644
--- a/include/iprt/env.h
+++ b/include/iprt/env.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -89,6 +89,8 @@ RTDECL(int) RTEnvDestroy(RTENV Env);
* @returns NULL if Env is NULL or invalid.
*
* @param Env Environment block handle.
+ * @todo This needs to change to return a copy of the env vars like
+ * RTEnvQueryUtf16Block does!
*/
RTDECL(char const * const *) RTEnvGetExecEnvP(RTENV Env);
@@ -120,6 +122,8 @@ RTDECL(void) RTEnvFreeUtf16Block(PRTUTF16 pwszzBlock);
* codeset conversion. We'll figure this out when it becomes necessary.
*/
RTDECL(bool) RTEnvExist(const char *pszVar);
+RTDECL(bool) RTEnvExistsBad(const char *pszVar);
+RTDECL(bool) RTEnvExistsUtf8(const char *pszVar);
/**
* Checks if an environment variable exists in a specific environment block.
@@ -145,6 +149,8 @@ RTDECL(bool) RTEnvExistEx(RTENV Env, const char *pszVar);
* codeset conversion. We'll figure this out when it becomes necessary.
*/
RTDECL(const char *) RTEnvGet(const char *pszVar);
+RTDECL(const char *) RTEnvGetBad(const char *pszVar);
+RTDECL(int) RTEnvGetUtf8(const char *pszVar, char *pszValue, size_t cbValue, size_t *pcchActual);
/**
* Gets an environment variable in a specific environment block.
@@ -173,6 +179,8 @@ RTDECL(int) RTEnvGetEx(RTENV Env, const char *pszVar, char *pszValue, size_t cbV
* codeset conversion. We'll figure this out when it becomes necessary.
*/
RTDECL(int) RTEnvPut(const char *pszVarEqualValue);
+RTDECL(int) RTEnvPutBad(const char *pszVarEqualValue);
+RTDECL(int) RTEnvPutUtf8(const char *pszVarEqualValue);
/**
* Puts a copy of the passed in 'variable=value' string into the environment block.
@@ -197,6 +205,8 @@ RTDECL(int) RTEnvPutEx(RTENV Env, const char *pszVarEqualValue);
* codeset conversion. We'll figure this out when it becomes necessary.
*/
RTDECL(int) RTEnvSet(const char *pszVar, const char *pszValue);
+RTDECL(int) RTEnvSetBad(const char *pszVar, const char *pszValue);
+RTDECL(int) RTEnvSetUtf8(const char *pszVar, const char *pszValue);
/**
* Sets an environment variable (setenv(,,1)).
@@ -221,6 +231,8 @@ RTDECL(int) RTEnvSetEx(RTENV Env, const char *pszVar, const char *pszValue);
* codeset conversion. We'll figure this out when it becomes necessary.
*/
RTDECL(int) RTEnvUnset(const char *pszVar);
+RTDECL(int) RTEnvUnsetBad(const char *pszVar);
+RTDECL(int) RTEnvUnsetUtf8(const char *pszVar);
/**
* Removes an environment variable from the specified environment block.
diff --git a/include/iprt/err.h b/include/iprt/err.h
index 13b9914f..5a613d84 100644
--- a/include/iprt/err.h
+++ b/include/iprt/err.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -654,6 +654,8 @@ RT_C_DECLS_END
#define VERR_VERSION_MISMATCH (-11)
/** The request function is not implemented. */
#define VERR_NOT_IMPLEMENTED (-12)
+/** Invalid flags was given. */
+#define VERR_INVALID_FLAGS (-13)
/** Not equal. */
#define VERR_NOT_EQUAL (-18)
@@ -875,6 +877,12 @@ RT_C_DECLS_END
#define VERR_UNEVEN_INPUT (-22402)
/** Something is not available or not working properly. */
#define VERR_NOT_AVAILABLE (-22403)
+/** The RTPROC_FLAGS_DETACHED flag isn't supported. */
+#define VERR_PROC_DETACH_NOT_SUPPORTED (-22404)
+/** An account is restricted in a certain way. */
+#define VERR_ACCOUNT_RESTRICTED (-22405)
+/** An account is restricted in a certain way. */
+#define VINF_ACCOUNT_RESTRICTED 22405
/** @} */
@@ -976,6 +984,8 @@ RT_C_DECLS_END
#define VERR_PATH_IS_RELATIVE (-143)
/** A path is not relative (start with root), expected an relative path. */
#define VERR_PATH_IS_NOT_RELATIVE (-144)
+/** Zero length path. */
+#define VERR_PATH_ZERO_LENGTH (-145)
/** @} */
@@ -1473,6 +1483,36 @@ RT_C_DECLS_END
#define VERR_DWARF_UNKNOWN_FORM (-677)
/** Encountered an unexpected attribute form. */
#define VERR_DWARF_UNEXPECTED_FORM (-678)
+/** Unfinished code. */
+#define VERR_DWARF_TODO (-679)
+/** Unknown location opcode. */
+#define VERR_DWARF_UNKNOWN_LOC_OPCODE (-680)
+/** Expression stack overflow. */
+#define VERR_DWARF_STACK_OVERFLOW (-681)
+/** Expression stack underflow. */
+#define VERR_DWARF_STACK_UNDERFLOW (-682)
+/** Internal processing error in the DWARF code. */
+#define VERR_DWARF_IPE (-683)
+/** Invalid configuration property value. */
+#define VERR_DBG_CFG_INVALID_VALUE (-684)
+/** Not an integer property. */
+#define VERR_DBG_CFG_NOT_UINT_PROP (-685)
+/** Deferred loading of information failed. */
+#define VERR_DBG_DEFERRED_LOAD_FAILED (-686)
+/** Unfinished debug info reader code. */
+#define VERR_DBG_TODO (-687)
+/** Found file, but it didn't match the search criteria. */
+#define VERR_DBG_FILE_MISMATCH (-688)
+/** Internal processing error in the debug module reader code. */
+#define VERR_DBG_MOD_IPE (-689)
+/** The symbol size was adjusted while adding it. */
+#define VINF_DBG_ADJUSTED_SYM_SIZE 690
+/** Unable to parse the CodeView debug information. */
+#define VERR_CV_BAD_FORMAT (-691)
+/** Unfinished CodeView debug information feature. */
+#define VERR_CV_TODO (-692)
+/** Internal processing error the CodeView debug information reader. */
+#define VERR_CV_IPE (-693)
/** @} */
/** @name Request Packet Status Codes.
@@ -1563,6 +1603,28 @@ RT_C_DECLS_END
#define VERR_S3_CANCELED (-879)
/** @} */
+/** @name HTTP status codes
+ * @{ */
+/** HTTP initialization failed. */
+#define VERR_HTTP_INIT_FAILED (-885)
+/** The server has not found anything matching the URI given. */
+#define VERR_HTTP_NOT_FOUND (-886)
+/** The request is for something forbidden. Authorization will not help. */
+#define VERR_HTTP_ACCESS_DENIED (-887)
+/** The server did not understand the request due to bad syntax. */
+#define VERR_HTTP_BAD_REQUEST (-888)
+/** Couldn't connect to the server (proxy?). */
+#define VERR_HTTP_COULDNT_CONNECT (-889)
+/** SSL connection error. */
+#define VERR_HTTP_SSL_CONNECT_ERROR (-890)
+/** CAcert is missing or has the wrong format. */
+#define VERR_HTTP_CACERT_WRONG_FORMAT (-891)
+/** Certificate cannot be authenticated with the given CA certificates. */
+#define VERR_HTTP_CACERT_CANNOT_AUTHENTICATE (-892)
+/** The current HTTP request was forcefully aborted */
+#define VERR_HTTP_ABORTED (-893)
+/** @} */
+
/** @name RTManifest status codes
* @{ */
/** A digest type used in the manifest file isn't supported. */
@@ -1633,6 +1695,8 @@ RT_C_DECLS_END
#define VERR_TAR_MALFORMED_GNU_LONGXXXX (-946)
/** Too long name or link string. */
#define VERR_TAR_NAME_TOO_LONG (-947)
+/** A directory entry in the archive. */
+#define VINF_TAR_DIR_PATH (948)
/** @} */
/** @name RTPoll status codes
@@ -1724,6 +1788,96 @@ RT_C_DECLS_END
#define VERR_FILESYSTEM_CORRUPT (-22600)
/** @} */
+/** @name RTZipXar status codes.
+ * @{ */
+/** Wrong magic value. */
+#define VERR_XAR_WRONG_MAGIC (-22700)
+/** Bad header size. */
+#define VERR_XAR_BAD_HDR_SIZE (-22701)
+/** Unsupported version. */
+#define VERR_XAR_UNSUPPORTED_VERSION (-22702)
+/** Unsupported hashing function. */
+#define VERR_XAR_UNSUPPORTED_HASH_FUNCTION (-22703)
+/** The table of content (TOC) is too small and therefore can't be valid. */
+#define VERR_XAR_TOC_TOO_SMALL (-22704)
+/** The table of content (TOC) is too big. */
+#define VERR_XAR_TOC_TOO_BIG (-22705)
+/** The compressed table of content is too big. */
+#define VERR_XAR_TOC_TOO_BIG_COMPRESSED (-22706)
+/** The uncompressed table of content size in the header didn't match what
+ * ZLib returned. */
+#define VERR_XAR_TOC_UNCOMP_SIZE_MISMATCH (-22707)
+/** The table of content string length didn't match the size specified in the
+ * header. */
+#define VERR_XAR_TOC_STRLEN_MISMATCH (-22708)
+/** The table of content isn't valid UTF-8. */
+#define VERR_XAR_TOC_UTF8_ENCODING (-22709)
+/** XML error while parsing the table of content. */
+#define VERR_XAR_TOC_XML_PARSE_ERROR (-22710)
+/** The table of content XML document does not have a toc element. */
+#define VERR_XML_TOC_ELEMENT_MISSING (-22711)
+/** The table of content XML element (toc) has sibilings, we expected it to be
+ * an only child or the root element (xar). */
+#define VERR_XML_TOC_ELEMENT_HAS_SIBLINGS (-22712)
+/** The XAR table of content digest doesn't match. */
+#define VERR_XAR_TOC_DIGEST_MISMATCH (-22713)
+/** Bad or missing XAR checksum element. */
+#define VERR_XAR_BAD_CHECKSUM_ELEMENT (-22714)
+/** The hash function in the header doesn't match the one in the table of
+ * content. */
+#define VERR_XAR_HASH_FUNCTION_MISMATCH (-22715)
+/** Bad digest length encountered in the table of content. */
+#define VERR_XAR_BAD_DIGEST_LENGTH (-22716)
+/** The order of elements in the XAR file does not lend it self to expansion
+ * from via an I/O stream. */
+#define VERR_XAR_NOT_STREAMBLE_ELEMENT_ORDER (-22717)
+/** Missing offset element in table of content sub-element. */
+#define VERR_XAR_MISSING_OFFSET_ELEMENT (-22718)
+/** Bad offset element in table of content sub-element. */
+#define VERR_XAR_BAD_OFFSET_ELEMENT (-22719)
+/** Missing size element in table of content sub-element. */
+#define VERR_XAR_MISSING_SIZE_ELEMENT (-22720)
+/** Bad size element in table of content sub-element. */
+#define VERR_XAR_BAD_SIZE_ELEMENT (-22721)
+/** Missing length element in table of content sub-element. */
+#define VERR_XAR_MISSING_LENGTH_ELEMENT (-22722)
+/** Bad length element in table of content sub-element. */
+#define VERR_XAR_BAD_LENGTH_ELEMENT (-22723)
+/** Bad file element in XAR table of content. */
+#define VERR_XAR_BAD_FILE_ELEMENT (-22724)
+/** Missing data element for XAR file. */
+#define VERR_XAR_MISSING_DATA_ELEMENT (-22725)
+/** Unknown XAR file type value. */
+#define VERR_XAR_UNKNOWN_FILE_TYPE (-22726)
+/** Missing encoding element for XAR data stream. */
+#define VERR_XAR_NO_ENCODING (-22727)
+/** Bad timestamp for XAR file. */
+#define VERR_XAR_BAD_FILE_TIMESTAMP (-22728)
+/** Bad file mode for XAR file. */
+#define VERR_XAR_BAD_FILE_MODE (-22729)
+/** Bad file user id for XAR file. */
+#define VERR_XAR_BAD_FILE_UID (-22730)
+/** Bad file group id for XAR file. */
+#define VERR_XAR_BAD_FILE_GID (-22731)
+/** Bad file inode device number for XAR file. */
+#define VERR_XAR_BAD_FILE_DEVICE_NO (-22732)
+/** Bad file inode number for XAR file. */
+#define VERR_XAR_BAD_FILE_INODE (-22733)
+/** Invalid name for XAR file. */
+#define VERR_XAR_INVALID_FILE_NAME (-22734)
+/** The message digest of the extracted data does not match the one supplied. */
+#define VERR_XAR_EXTRACTED_HASH_MISMATCH (-22735)
+/** The extracted data has exceeded the expected size. */
+#define VERR_XAR_EXTRACTED_SIZE_EXCEEDED (-22736)
+/** The message digest of the archived data does not match the one supplied. */
+#define VERR_XAR_ARCHIVED_HASH_MISMATCH (-22737)
+/** The decompressor completed without using all the input data. */
+#define VERR_XAR_UNUSED_ARCHIVED_DATA (-22738)
+/** Expected the archived and extracted XAR data sizes to be the same for
+ * uncompressed data. */
+#define VERR_XAR_ARCHIVED_AND_EXTRACTED_SIZES_MISMATCH (-22739)
+/** @} */
+
/* SED-END */
diff --git a/include/iprt/err.mac b/include/iprt/err.mac
index 00e330cc..39ac4e91 100644
--- a/include/iprt/err.mac
+++ b/include/iprt/err.mac
@@ -15,6 +15,7 @@
%define VINF_PERMISSION_DENIED 10
%define VERR_VERSION_MISMATCH (-11)
%define VERR_NOT_IMPLEMENTED (-12)
+%define VERR_INVALID_FLAGS (-13)
%define VERR_NOT_EQUAL (-18)
%define VERR_NOT_SYMLINK (-19)
%define VERR_NO_TMP_MEMORY (-20)
@@ -121,6 +122,9 @@
%define VINF_BUFFER_UNDERFLOW 22401
%define VERR_UNEVEN_INPUT (-22402)
%define VERR_NOT_AVAILABLE (-22403)
+%define VERR_PROC_DETACH_NOT_SUPPORTED (-22404)
+%define VERR_ACCOUNT_RESTRICTED (-22405)
+%define VINF_ACCOUNT_RESTRICTED 22405
%define VERR_FILE_IO_ERROR (-100)
%define VERR_OPEN_FAILED (-101)
%define VERR_FILE_NOT_FOUND (-102)
@@ -168,6 +172,7 @@
%define VERR_PATH_DOES_NOT_START_WITH_ROOT (-142)
%define VERR_PATH_IS_RELATIVE (-143)
%define VERR_PATH_IS_NOT_RELATIVE (-144)
+%define VERR_PATH_ZERO_LENGTH (-145)
%define VERR_DISK_IO_ERROR (-150)
%define VERR_INVALID_DRIVE (-151)
%define VERR_DISK_FULL (-152)
@@ -274,6 +279,7 @@
%define VERR_NET_HOST_DOWN (-464)
%define VERR_NET_HOST_UNREACHABLE (-465)
%define VERR_NET_PROTOCOL_ERROR (-466)
+%define VERR_NET_INCOMPLETE_TX_PACKET (-467)
%define VERR_TCP_SERVER_STOP (-500)
%define VINF_TCP_SERVER_STOP 500
%define VERR_TCP_SERVER_SHUTDOWN (-501)
@@ -371,6 +377,21 @@
%define VERR_DWARF_ABBREV_NOT_FOUND (-676)
%define VERR_DWARF_UNKNOWN_FORM (-677)
%define VERR_DWARF_UNEXPECTED_FORM (-678)
+%define VERR_DWARF_TODO (-679)
+%define VERR_DWARF_UNKNOWN_LOC_OPCODE (-680)
+%define VERR_DWARF_STACK_OVERFLOW (-681)
+%define VERR_DWARF_STACK_UNDERFLOW (-682)
+%define VERR_DWARF_IPE (-683)
+%define VERR_DBG_CFG_INVALID_VALUE (-684)
+%define VERR_DBG_CFG_NOT_UINT_PROP (-685)
+%define VERR_DBG_DEFERRED_LOAD_FAILED (-686)
+%define VERR_DBG_TODO (-687)
+%define VERR_DBG_FILE_MISMATCH (-688)
+%define VERR_DBG_MOD_IPE (-689)
+%define VINF_DBG_ADJUSTED_SYM_SIZE 690
+%define VERR_CV_BAD_FORMAT (-691)
+%define VERR_CV_TODO (-692)
+%define VERR_CV_IPE (-693)
%define VERR_RT_REQUEST_INVALID_TYPE (-700)
%define VERR_RT_REQUEST_STATE (-701)
%define VERR_RT_REQUEST_INVALID_PACKAGE (-702)
@@ -394,6 +415,15 @@
%define VERR_S3_BUCKET_ALREADY_EXISTS (-877)
%define VERR_S3_BUCKET_NOT_EMPTY (-878)
%define VERR_S3_CANCELED (-879)
+%define VERR_HTTP_INIT_FAILED (-885)
+%define VERR_HTTP_NOT_FOUND (-886)
+%define VERR_HTTP_ACCESS_DENIED (-887)
+%define VERR_HTTP_BAD_REQUEST (-888)
+%define VERR_HTTP_COULDNT_CONNECT (-889)
+%define VERR_HTTP_SSL_CONNECT_ERROR (-890)
+%define VERR_HTTP_CACERT_WRONG_FORMAT (-891)
+%define VERR_HTTP_CACERT_CANNOT_AUTHENTICATE (-892)
+%define VERR_HTTP_ABORTED (-893)
%define VERR_MANIFEST_UNSUPPORTED_DIGEST_TYPE (-900)
%define VERR_MANIFEST_WRONG_FILE_FORMAT (-901)
%define VERR_MANIFEST_DIGEST_MISMATCH (-902)
@@ -424,6 +454,7 @@
%define VERR_TAR_BAD_CHKSUM_FIELD (-945)
%define VERR_TAR_MALFORMED_GNU_LONGXXXX (-946)
%define VERR_TAR_NAME_TOO_LONG (-947)
+%define VINF_TAR_DIR_PATH (948)
%define VERR_POLL_HANDLE_NOT_POLLABLE (-950)
%define VERR_POLL_HANDLE_ID_EXISTS (-951)
%define VERR_POLL_HANDLE_ID_NOT_FOUND (-952)
@@ -453,3 +484,43 @@
%define VINF_SYS_MAY_POWER_OFF (22501)
%define VERR_SYS_SHUTDOWN_FAILED (-22502)
%define VERR_FILESYSTEM_CORRUPT (-22600)
+%define VERR_XAR_WRONG_MAGIC (-22700)
+%define VERR_XAR_BAD_HDR_SIZE (-22701)
+%define VERR_XAR_UNSUPPORTED_VERSION (-22702)
+%define VERR_XAR_UNSUPPORTED_HASH_FUNCTION (-22703)
+%define VERR_XAR_TOC_TOO_SMALL (-22704)
+%define VERR_XAR_TOC_TOO_BIG (-22705)
+%define VERR_XAR_TOC_TOO_BIG_COMPRESSED (-22706)
+%define VERR_XAR_TOC_UNCOMP_SIZE_MISMATCH (-22707)
+%define VERR_XAR_TOC_STRLEN_MISMATCH (-22708)
+%define VERR_XAR_TOC_UTF8_ENCODING (-22709)
+%define VERR_XAR_TOC_XML_PARSE_ERROR (-22710)
+%define VERR_XML_TOC_ELEMENT_MISSING (-22711)
+%define VERR_XML_TOC_ELEMENT_HAS_SIBLINGS (-22712)
+%define VERR_XAR_TOC_DIGEST_MISMATCH (-22713)
+%define VERR_XAR_BAD_CHECKSUM_ELEMENT (-22714)
+%define VERR_XAR_HASH_FUNCTION_MISMATCH (-22715)
+%define VERR_XAR_BAD_DIGEST_LENGTH (-22716)
+%define VERR_XAR_NOT_STREAMBLE_ELEMENT_ORDER (-22717)
+%define VERR_XAR_MISSING_OFFSET_ELEMENT (-22718)
+%define VERR_XAR_BAD_OFFSET_ELEMENT (-22719)
+%define VERR_XAR_MISSING_SIZE_ELEMENT (-22720)
+%define VERR_XAR_BAD_SIZE_ELEMENT (-22721)
+%define VERR_XAR_MISSING_LENGTH_ELEMENT (-22722)
+%define VERR_XAR_BAD_LENGTH_ELEMENT (-22723)
+%define VERR_XAR_BAD_FILE_ELEMENT (-22724)
+%define VERR_XAR_MISSING_DATA_ELEMENT (-22725)
+%define VERR_XAR_UNKNOWN_FILE_TYPE (-22726)
+%define VERR_XAR_NO_ENCODING (-22727)
+%define VERR_XAR_BAD_FILE_TIMESTAMP (-22728)
+%define VERR_XAR_BAD_FILE_MODE (-22729)
+%define VERR_XAR_BAD_FILE_UID (-22730)
+%define VERR_XAR_BAD_FILE_GID (-22731)
+%define VERR_XAR_BAD_FILE_DEVICE_NO (-22732)
+%define VERR_XAR_BAD_FILE_INODE (-22733)
+%define VERR_XAR_INVALID_FILE_NAME (-22734)
+%define VERR_XAR_EXTRACTED_HASH_MISMATCH (-22735)
+%define VERR_XAR_EXTRACTED_SIZE_EXCEEDED (-22736)
+%define VERR_XAR_ARCHIVED_HASH_MISMATCH (-22737)
+%define VERR_XAR_UNUSED_ARCHIVED_DATA (-22738)
+%define VERR_XAR_ARCHIVED_AND_EXTRACTED_SIZES_MISMATCH (-22739)
diff --git a/include/iprt/err.sed b/include/iprt/err.sed
index 2271331c..89cfeafd 100644
--- a/include/iprt/err.sed
+++ b/include/iprt/err.sed
@@ -3,7 +3,7 @@
#
#
-# Copyright (C) 2006-2009 Oracle Corporation
+# Copyright (C) 2006-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;
diff --git a/include/iprt/file.h b/include/iprt/file.h
index 3357ab23..616daceb 100644
--- a/include/iprt/file.h
+++ b/include/iprt/file.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2011 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -30,6 +30,7 @@
#include <iprt/types.h>
#include <iprt/stdarg.h>
#include <iprt/fs.h>
+#include <iprt/sg.h>
RT_C_DECLS_BEGIN
@@ -147,7 +148,7 @@ RTDECL(int) RTFileQuerySize(const char *pszPath, uint64_t *pcbFile);
#define RTFILE_O_NOT_CONTENT_INDEXED UINT32_C(0x00000800)
/** Truncate the file.
* @remarks This will not truncate files opened for read-only.
- * @remarks The trunction doesn't have to be atomically, so anyone else opening
+ * @remarks The truncation doesn't have to be atomically, so anyone else opening
* the file may be racing us. The caller is responsible for not causing
* this race. */
#define RTFILE_O_TRUNCATE UINT32_C(0x00001000)
@@ -381,6 +382,20 @@ RTDECL(int) RTFileRead(RTFILE File, void *pvBuf, size_t cbToRead, size_t *pcbRe
RTDECL(int) RTFileReadAt(RTFILE File, RTFOFF off, void *pvBuf, size_t cbToRead, size_t *pcbRead);
/**
+ * Read bytes from a file at a given offset into a S/G buffer.
+ * This function may modify the file position.
+ *
+ * @returns iprt status code.
+ * @param hFile Handle to the file.
+ * @param off Where to read.
+ * @param pSgBuf Pointer to the S/G buffer to read into.
+ * @param cbToRead How much to read.
+ * @param *pcbRead How much we actually read .
+ * If NULL an error will be returned for a partial read.
+ */
+RTDECL(int) RTFileSgReadAt(RTFILE hFile, RTFOFF off, PRTSGBUF pSgBuf, size_t cbToRead, size_t *pcbRead);
+
+/**
* Write bytes to a file.
*
* @returns iprt status code.
@@ -407,6 +422,20 @@ RTDECL(int) RTFileWrite(RTFILE File, const void *pvBuf, size_t cbToWrite, size_
RTDECL(int) RTFileWriteAt(RTFILE File, RTFOFF off, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten);
/**
+ * Write bytes from a S/G buffer to a file at a given offset.
+ * This function may modify the file position.
+ *
+ * @returns iprt status code.
+ * @param hFile Handle to the file.
+ * @param off Where to write.
+ * @param pSgBuf What to write.
+ * @param cbToWrite How much to write.
+ * @param *pcbWritten How much we actually wrote.
+ * If NULL an error will be returned for a partial write.
+ */
+RTDECL(int) RTFileSgWriteAt(RTFILE hFile, RTFOFF off, PRTSGBUF pSgBuf, size_t cbToWrite, size_t *pcbWritten);
+
+/**
* Flushes the buffers for the specified file.
*
* @returns iprt status code.
@@ -571,6 +600,54 @@ RTDECL(int) RTFileRename(const char *pszSrc, const char *pszDst, unsigned fRenam
/** @} */
/**
+ * Converts file opening modes (used by fopen, for example) to IPRT
+ * compatible flags, which then can be used with RTFileOpen* APIs.
+ *
+ * Note: Handling sharing modes is not supported yet, so RTFILE_O_DENY_NONE
+ * will be used by default.
+ *
+ * @return IPRT status code.
+ * @param pszMode Mode string to convert.
+ * @param puMode Where to store the converted mode flags
+ * on success.
+ */
+RTDECL(int) RTFileModeToFlags(const char *pszMode, uint64_t *puMode);
+
+/**
+ * Converts file opening modes along with a separate disposition command
+ * to IPRT compatible flags, which then can be used with RTFileOpen* APIs.
+ *
+ * Access modes:
+ * "r" - Opens a file for reading.
+ * "r+" - Opens a file for reading and writing.
+ * "w" - Opens a file for writing.
+ * "w+" - Opens a file for writing and reading.
+ *
+ * Disposition modes:
+ * "ca" - Creates a new file, always. Overwrites an existing file.
+ * "ce" - Creates a new file if it does not exist. Fail if exist.
+ * "oa" - Opens an existing file and places the file pointer at
+ * the end of the file, if opened with write access.
+ * Create the file if it does not exist.
+ * "oc" - Opens an existing file or create it if it does not exist.
+ * "oe" - Opens an existing file or fail if it does not exist.
+ * "ot" - Opens and truncate an existing file or fail if it does not exist.
+ *
+ * Sharing modes:
+ * Not implemented yet. RTFILE_O_DENY_NONE will be
+ * used by default.
+ *
+ * @return IPRT status code.
+ * @param pszAccess Access mode string to convert.
+ * @param pszDisposition Disposition mode string to convert.
+ * @param pszSharing Sharing mode string to convert. Not
+ * implemented yet.
+ * @param puMode Where to store the converted mode flags
+ * on success.
+ */
+RTDECL(int) RTFileModeToFlagsEx(const char *pszAccess, const char *pszDisposition, const char *pszSharing, uint64_t *puMode);
+
+/**
* Moves a file.
*
* RTFileMove differs from RTFileRename in that it works across volumes.
@@ -1215,13 +1292,22 @@ RTDECL(int) RTFileAioReqGetRC(RTFILEAIOREQ hReq, size_t *pcbTransferred);
* to handle. Pass RTFILEAIO_UNLIMITED_REQS if the
* context should support an unlimited number of
* requests.
+ * @param fFlags Combination of RTFILEAIOCTX_FLAGS_*.
*/
-RTDECL(int) RTFileAioCtxCreate(PRTFILEAIOCTX phAioCtx, uint32_t cAioReqsMax);
+RTDECL(int) RTFileAioCtxCreate(PRTFILEAIOCTX phAioCtx, uint32_t cAioReqsMax,
+ uint32_t fFlags);
/** Unlimited number of requests.
* Used with RTFileAioCtxCreate and RTFileAioCtxGetMaxReqCount. */
#define RTFILEAIO_UNLIMITED_REQS UINT32_MAX
+/** When set RTFileAioCtxWait() will always wait for completing requests,
+ * even when there is none waiting currently, instead of returning
+ * VERR_FILE_AIO_NO_REQUEST. */
+#define RTFILEAIOCTX_FLAGS_WAIT_WITHOUT_PENDING_REQUESTS RT_BIT_32(0)
+/** mask of valid flags. */
+#define RTFILEAIOCTX_FLAGS_VALID_MASK (RTFILEAIOCTX_FLAGS_WAIT_WITHOUT_PENDING_REQUESTS)
+
/**
* Destroys an async I/O context.
*
diff --git a/include/iprt/formats/Makefile.kup b/include/iprt/formats/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/include/iprt/formats/Makefile.kup
diff --git a/include/iprt/formats/codeview.h b/include/iprt/formats/codeview.h
new file mode 100644
index 00000000..b40e8f64
--- /dev/null
+++ b/include/iprt/formats/codeview.h
@@ -0,0 +1,82 @@
+/** @file
+ * IPRT - Microsoft CodeView Debug Information.
+ */
+
+/*
+ * Copyright (C) 2009-2013 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.
+ */
+
+#ifndef ___iprt_formats_codeview_h
+#define ___iprt_formats_codeview_h
+
+
+#include <iprt/types.h>
+#include <iprt/assert.h>
+
+
+/** @defgroup grp_rt_fmt_codeview Microsoft CodeView Debug Information
+ * @{
+ */
+/**
+ * PDB v2.0 in image debug info.
+ * The URL is constructed from the timestamp and age?
+ */
+typedef struct CVPDB20INFO
+{
+ uint32_t u32Magic; /**< CVPDB20INFO_SIGNATURE. */
+ int32_t offDbgInfo; /**< Always 0. Used to be the offset to the real debug info. */
+ uint32_t uTimestamp;
+ uint32_t uAge;
+ uint8_t szPdbFilename[4];
+} CVPDB20INFO;
+/** Pointer to in executable image PDB v2.0 info. */
+typedef CVPDB20INFO *PCVPDB20INFO;
+/** Pointer to read only in executable image PDB v2.0 info. */
+typedef CVPDB20INFO const *PCCVPDB20INFO;
+/** The CVPDB20INFO magic value. */
+#define CVPDB20INFO_MAGIC RT_MAKE_U32_FROM_U8('N','B','1','0')
+
+/**
+ * PDB v7.0 in image debug info.
+ * The URL is constructed from the signature and the age.
+ */
+#pragma pack(4)
+typedef struct CVPDB70INFO
+{
+ uint32_t u32Magic; /**< CVPDB70INFO_SIGNATURE. */
+ RTUUID PdbUuid;
+ uint32_t uAge;
+ uint8_t szPdbFilename[4];
+} CVPDB70INFO;
+#pragma pack()
+AssertCompileMemberOffset(CVPDB70INFO, PdbUuid, 4);
+AssertCompileMemberOffset(CVPDB70INFO, uAge, 4 + 16);
+/** Pointer to in executable image PDB v7.0 info. */
+typedef CVPDB70INFO *PCVPDB70INFO;
+/** Pointer to read only in executable image PDB v7.0 info. */
+typedef CVPDB70INFO const *PCCVPDB70INFO;
+/** The CVPDB70INFO magic value. */
+#define CVPDB70INFO_MAGIC RT_MAKE_U32_FROM_U8('R','S','D','S')
+
+
+/** @} */
+
+#endif
+
diff --git a/include/iprt/formats/hfs.h b/include/iprt/formats/hfs.h
new file mode 100644
index 00000000..77d31b6a
--- /dev/null
+++ b/include/iprt/formats/hfs.h
@@ -0,0 +1,677 @@
+/** @file
+ * IPRT - Hierarchical File System (HFS).
+ */
+
+/*
+ * Copyright (C) 2009-2013 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.
+ */
+
+#ifndef ___iprt_formats_hfs_h
+#define ___iprt_formats_hfs_h
+
+
+#include <iprt/types.h>
+#include <iprt/assert.h>
+
+
+/** @defgroup grp_rt_fmt_hfs HFS - Hierarchical File System.
+ * @{
+ */
+
+
+/** @name HFS signature words (HFSPlusVolumeHeader::signature)
+ * @{ */
+#define kHFSSigWord UINT16_C(0x4244)
+#define kHFSPlusSigWord UINT16_C(0x482b)
+#define kHFSXSigWord UINT16_C(0x4858)
+/** @} */
+
+/** @name HFS version numbers (HFSPlusVolumeHeader::version).
+ * @{ */
+#define kHFSPlusVersion UINT16_C(4)
+#define kHFSXVersion UINT16_C(5)
+/** @} */
+
+/** @name HFS mount version numbers (HFSPlusVolumeHeader::lastMountedVersion).
+ * @{ */
+#define kHFSPlusMountVersion UINT32_C(0x31302e30)
+#define kHFSJMountVersion UINT32_C(0x4846534a)
+#define kFSKMountVersion UINT32_C(0x46534b21)
+/** @} */
+
+/** @name Hard link file creators & types.
+ * @{ */
+#define kHardLinkFileType UINT32_C(0x686c6e6b)
+#define kHFSPlusCreator UINT32_C(0x6866732b)
+/** @} */
+
+/** @name Symlink file creators & types.
+ * @{ */
+#define kSymLinkFileType UINT32_C(0x736c6e6b)
+#define kSymLinkCreator UINT32_C(0x72686170)
+/** @} */
+
+/** @name Name limits.
+ * @{ */
+#define kHFSMaxVolumeNameChars UINT8_C(0x1b)
+#define kHFSMaxFileNameChars UINT8_C(0x1f)
+#define kHFSPlusMaxFileNameChars UINT8_C(0xff)
+#define kHFSMaxAttrNameLen UINT8_C(0x7f)
+/** @} */
+
+/** @name Extent descriptor record densities
+ * @{ */
+#define kHFSExtentDensity UINT8_C(3)
+#define kHFSPlusExtentDensity UINT8_C(8)
+/** @} */
+
+
+/** @name File IDs (various fileID members).
+ * @{ */
+#define kHFSRootParentID UINT32_C(0x00000001)
+#define kHFSRootFolderID UINT32_C(0x00000002)
+#define kHFSExtentsFileID UINT32_C(0x00000003)
+#define kHFSCatalogFileID UINT32_C(0x00000004)
+#define kHFSBadBlockFileID UINT32_C(0x00000005)
+#define kHFSAllocationFileID UINT32_C(0x00000006)
+#define kHFSStartupFileID UINT32_C(0x00000007)
+#define kHFSAttributesFileID UINT32_C(0x00000008)
+#define kHFSAttributeDataFileID UINT32_C(0x0000000c)
+#define kHFSRepairCatalogFileID UINT32_C(0x0000000e)
+#define kHFSBogusExtentFileID UINT32_C(0x0000000f)
+#define kHFSFirstUserCatalogNodeID UINT32_C(0x00000010)
+/** @} */
+
+/** @name Catalog record types.
+ * @{ */
+#define kHFSFolderRecord UINT16_C(0x0100)
+#define kHFSFileRecord UINT16_C(0x0200)
+#define kHFSFolderThreadRecord UINT16_C(0x0300)
+#define kHFSFileThreadRecord UINT16_C(0x0400)
+#define kHFSPlusFolderRecord UINT16_C(0x0001)
+#define kHFSPlusFileRecord UINT16_C(0x0002)
+#define kHFSPlusFolderThreadRecord UINT16_C(0x0003)
+#define kHFSPlusFileThreadRecord UINT16_C(0x0004)
+/** @} */
+
+/** @name File record bits and masks.
+ * @{ */
+#define kHFSFileLockedBit 0
+#define kHFSThreadExistsBit 1
+#define kHFSHasAttributesBit 2
+#define kHFSHasSecurityBit 3
+#define kHFSHasFolderCountBit 4
+#define kHFSHasLinkChainBit 5
+#define kHFSHasChildLinkBit 6
+#define kHFSHasDateAddedBit 7
+
+#define kHFSFileLockedMask RT_BIT(kHFSFileLockedBit)
+#define kHFSThreadExistsMask RT_BIT(kHFSThreadExistsBit)
+#define kHFSHasAttributesMask RT_BIT(kHFSHasAttributesBit)
+#define kHFSHasSecurityMask RT_BIT(kHFSHasSecurityBit)
+#define kHFSHasFolderCountMask RT_BIT(kHFSHasFolderCountBit)
+#define kHFSHasLinkChainMask RT_BIT(kHFSHasLinkChainBit)
+#define kHFSHasChildLinkMask RT_BIT(kHFSHasChildLinkBit)
+#define kHFSHasDateAddedMask RT_BIT(kHFSHasDateAddedBit)
+/** @} */
+
+/** @name Key and node lengths.
+ * @{ */
+#define kHFSPlusAttrKeyMaximumLength ( sizeof(HFSPlusAttrKey) - sizeof(uint16_t) )
+#define kHFSPlusAttrKeyMinimumLength ( kHFSPlusAttrKeyMaximumLength - (kHFSMaxAttrNameLen * sizeof(uint16_t)) )
+#define kHFSPlusExtentKeyMaximumLength ( sizeof(HFSPlusExtentKey) - sizeof(uint16_t),
+#define kHFSExtentKeyMaximumLength ( sizeof(HFSExtentKey) - sizeof(uint8_t) )
+#define kHFSPlusCatalogKeyMaximumLength ( sizeof(HFSPlusCatalogKey) - sizeof(uint16_t) )
+#define kHFSPlusCatalogKeyMinimumLength ( kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(uint16_t) )
+#define kHFSCatalogKeyMaximumLength ( sizeof(HFSCatalogKey) - sizeof(uint8_t) )
+#define kHFSCatalogKeyMinimumLength ( kHFSCatalogKeyMaximumLength - kHFSMaxFileNameChars - 1 + sizeof(uint8_t) )
+#define kHFSPlusCatalogMinNodeSize UINT16_C(0x1000)
+#define kHFSPlusExtentMinNodeSize UINT16_C(0x0200)
+#define kHFSPlusAttrMinNodeSize UINT16_C(0x1000)
+/** @} */
+
+/** @name Volume Attribute bits and masks.
+ * @remarks HFS has only 16-bit wide field, HFS+ has 32-bit.
+ * @{ */
+#define kHFSVolumeHardwareLockBit 7
+#define kHFSVolumeUnmountedBit 8
+#define kHFSVolumeSparedBlocksBit 9
+#define kHFSVolumeNoCacheRequiredBit 10
+#define kHFSBootVolumeInconsistentBit 11
+#define kHFSCatalogNodeIDsReusedBit 12
+#define kHFSVolumeJournaledBit 13
+#define kHFSVolumeInconsistentBit 14
+#define kHFSVolumeSoftwareLockBit 15
+#define kHFSUnusedNodeFixBit 31
+#define kHFSContentProtectionBit 30
+
+#define kHFSVolumeHardwareLockMask RT_BIT(kHFSVolumeHardwareLockBit)
+#define kHFSVolumeUnmountedMask RT_BIT(kHFSVolumeUnmountedBit)
+#define kHFSVolumeSparedBlocksMask RT_BIT(kHFSVolumeSparedBlocksBit)
+#define kHFSVolumeNoCacheRequiredMask RT_BIT(kHFSVolumeNoCacheRequiredBit)
+#define kHFSBootVolumeInconsistentMask RT_BIT(kHFSBootVolumeInconsistentBit)
+#define kHFSCatalogNodeIDsReusedMask RT_BIT(kHFSCatalogNodeIDsReusedBit)
+#define kHFSVolumeJournaledMask RT_BIT(kHFSVolumeJournaledBit)
+#define kHFSVolumeInconsistentMask RT_BIT(kHFSVolumeInconsistentBit)
+#define kHFSVolumeSoftwareLockMask RT_BIT(kHFSVolumeSoftwareLockBit)
+#define kHFSUnusedNodeFixMask RT_BIT(kHFSUnusedNodeFixBit)
+#define kHFSContentProtectionMask RT_BIT(kHFSContentProtectionBit)
+
+#define kHFSMDBAttributesMask UINT16_C(0x8380)
+/** @} */
+
+/** @name Misc
+ * @{ */
+#define kHFSUnusedNodesFixDate UINT32_C(0xc5ef2480)
+
+#define HFSPLUSMETADATAFOLDER "\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80HFS+ Private Data"
+#define HFSPLUS_DIR_METADATA_FOLDER ".HFS+ Private Directory Data\xd"
+#define HFS_INODE_PREFIX "iNode"
+#define HFS_DELETE_PREFIX "temp"
+#define HFS_DIRINODE_PREFIX "dir_"
+#define FIRST_LINK_XATTR_NAME "com.apple.system.hfs.firstlink"
+#define FIRST_LINK_XATTR_REC_SIZE ( sizeof(HFSPlusAttrData) + 10 )
+
+/* {b3e20f39-f292-11d6-97a4-00306543ecac} */
+#define HFS_UUID_NAMESPACE_ID "\xB3\xE2\x0F\x39\xF2\x92\x11\xD6\x97\xA4\x00\x30\x65\x43\xEC\xAC"
+
+#define SET_HFS_TEXT_ENCODING(a_uHint) (UINT32_C(0x656e6300) | (uint8_t)(a_uHint))
+#define GET_HFS_TEXT_ENCODING(a_uHint) ( ((a_uHint) & UINT32_C(0xffffff00)) == UINT32_C(0x656e6300) \
+ ? UINT32_C(0x000000ff)(a_uHint) : UINT32_MAX)
+/** @} */
+
+/** @name B-tree stuff.
+ * @{ */
+#define kMaxKeyLength 520
+
+#define kBTLeafNode (-1)
+#define kBTIndexNode 0
+#define kBTHeaderNode 1
+#define kBTMapNode 2
+
+#define kBTBadCloseMask RT_BIT_32(0)
+#define kBTBigKeysMask RT_BIT_32(1)
+#define kBTVariableIndexKeysMask RT_BIT_32(2)
+
+/** @} */
+
+/** @name B-tree compare types (BTHeaderRec::keyCompareType) */
+#define kHFSCaseFolding UINT8_C(0xcf)
+#define kHFSBinaryCompare UINT8_C(0xbc)
+/** @} */
+
+/** @name Journal stuff.
+ * @{ */
+#define JIB_RESERVED_SIZE ( sizeof(uint32_t) * 32 - 85 )
+
+#define kJIJournalInFSMask RT_BIT_32(0)
+#define kJIJournalOnOtherDeviceMask RT_BIT_32(1)
+#define kJIJournalNeedInitMask RT_BIT_32(2)
+
+#define EXTJNL_CONTENT_TYPE_UUID "4a6f7572-6e61-11aa-aa11-00306543ecac"
+/** @} */
+
+
+
+typedef struct HFSUniStr255
+{
+ uint16_t length;
+ RTUTF16 unicode[255];
+} HFSUniStr255;
+AssertCompileSize(HFSUniStr255, 0x200);
+typedef const HFSUniStr255 * ConstHFSUniStr255Param;
+
+#pragma pack(1)
+typedef struct HFSExtentKey
+{
+ uint8_t keyLength;
+ uint8_t forkType;
+ uint32_t fileID; /**< Misaligned. */
+ uint16_t startBLock;
+} HFSExtentKey;
+#pragma pack()
+AssertCompileSize(HFSExtentKey, 8);
+
+typedef struct HFSPlusExtentKey
+{
+ uint16_t keyLength;
+ uint8_t forkType;
+ uint8_t pad;
+ uint32_t fileID;
+ uint32_t startBlock;
+} HFSPlusExtentKey;
+AssertCompileSize(HFSPlusExtentKey, 12);
+
+typedef struct HFSExtentDescriptor
+{
+ uint16_t startBlock;
+ uint16_t blockCount;
+} HFSExtentDescriptor;
+AssertCompileSize(HFSExtentDescriptor, 4);
+
+typedef struct HFSPlusExtentDescriptor
+{
+ uint32_t startBlock;
+ uint32_t blockCount;
+} HFSPlusExtentDescriptor;
+AssertCompileSize(HFSPlusExtentDescriptor, 8);
+
+typedef HFSExtentDescriptor HFSExtentRecord[3];
+typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
+
+typedef struct FndrFileInfo
+{
+ uint32_t fdType;
+ uint32_t fdCreator;
+ uint16_t fdFlags;
+ struct
+ {
+ int16_t v;
+ int16_t h;
+ } fdLocation;
+ uint16_t opaque;
+} FndrFileInfo;
+AssertCompileSize(FndrFileInfo, 16);
+
+typedef struct FndrDirInfo
+{
+ struct
+ {
+ int16_t top;
+ int16_t left;
+ int16_t bottom;
+ int16_t right;
+ } frRect;
+ uint16_t frFlags;
+ struct
+ {
+ int16_t v;
+ int16_t h;
+ } fdLocation;
+ uint16_t opaque;
+} FndrDirInfo;
+AssertCompileSize(FndrDirInfo, 16);
+
+typedef struct FndrOpaqueInfo
+{
+ int8_t opaque[16];
+} FndrOpaqueInfo;
+AssertCompileSize(FndrOpaqueInfo, 16);
+
+typedef struct FndrExtendedFileInfo
+{
+ uint32_t reserved1;
+ uint32_t date_added;
+ uint16_t extended_flags;
+ uint16_t reserved2;
+ uint32_t reserved3;
+} FndrExtendedFileInfo;
+AssertCompileSize(FndrExtendedFileInfo, 16);
+
+typedef struct FndrExtendedDirInfo
+{
+ uint32_t point;
+ uint32_t date_added;
+ uint16_t extended_flags;
+ uint16_t reserved3;
+ uint32_t reserved4;
+} FndrExtendedDirInfo;
+AssertCompileSize(FndrExtendedDirInfo, 16);
+
+typedef struct HFSPlusForkData
+{
+ uint64_t logicalSize;
+ uint32_t clumpSize;
+ uint32_t totalBlocks;
+ HFSPlusExtentRecord extents;
+} HFSPlusForkData;
+AssertCompileSize(HFSPlusForkData, 80);
+
+typedef struct HFSPlusBSDInfo
+{
+ uint32_t ownerID;
+ uint32_t groupID;
+ uint8_t adminFlags;
+ uint8_t ownerFlags;
+ uint16_t fileMode;
+ union
+ {
+ uint32_t iNodeNum;
+ uint32_t linkCount;
+ uint32_t rawDevice;
+ } special;
+} HFSPlusBSDInfo;
+AssertCompileSize(HFSPlusBSDInfo, 16);
+
+#pragma pack(1)
+typedef struct HFSCatalogKey
+{
+ uint8_t keyLength;
+ uint8_t reserved;
+ uint32_t parentID; /**< Misaligned. */
+ uint8_t nodeName[kHFSMaxFileNameChars + 1];
+} HFSCatalogKey;
+#pragma pack()
+AssertCompileSize(HFSCatalogKey, 0x26);
+
+#pragma pack(1)
+typedef struct HFSPlusCatalogKey
+{
+ uint16_t keyLength;
+ uint32_t parentID; /**< Misaligned. */
+ HFSUniStr255 nodeName;
+} HFSPlusCatalogKey;
+#pragma pack()
+AssertCompileSize(HFSPlusCatalogKey, 0x206);
+
+#pragma pack(1)
+typedef struct HFSCatalogFolder
+{
+ int16_t recordType;
+ uint16_t flags;
+ uint16_t valence;
+ uint32_t folderID; /**< Misaligned. */
+ uint32_t createDate; /**< Misaligned. */
+ uint32_t modifyDate; /**< Misaligned. */
+ uint32_t backupDate; /**< Misaligned. */
+ FndrDirInfo userInfo;
+ FndrOpaqueInfo finderInfo;
+ uint32_t reserved[4]; /**< Misaligned. */
+} HFSCatalogFolder;
+#pragma pack()
+AssertCompileSize(HFSCatalogFolder, 70);
+
+typedef struct HFSPlusCatalogFolder
+{
+ int16_t recordType;
+ uint16_t flags;
+ uint32_t valence;
+ uint32_t folderID;
+ uint32_t createDate;
+ uint32_t contentModDate;
+ uint32_t attributeModDate;
+ uint32_t accessDate;
+ uint32_t backupDate;
+ HFSPlusBSDInfo bsdInfo;
+ FndrDirInfo userInfo;
+ FndrOpaqueInfo finderInfo;
+ uint32_t textEncoding;
+ uint32_t folderCount;
+} HFSPlusCatalogFolder;
+AssertCompileSize(HFSPlusCatalogFolder, 88);
+
+#pragma pack(1)
+typedef struct HFSCatalogFile
+{
+ int16_t recordType;
+ uint8_t flags;
+ uint8_t fileType;
+ FndrFileInfo userInfo;
+ uint32_t fileID;
+ uint16_t dataStartBlock;
+ int32_t dataLogicalSize; /**< Misaligned. */
+ int32_t dataPhysicalSize; /**< Misaligned. */
+ uint16_t rsrcStartBlock;
+ int32_t rsrcLogicalSize;
+ int32_t rsrcPhysicalSize;
+ uint32_t createDate;
+ uint32_t modifyDate;
+ uint32_t backupDate;
+ FndrOpaqueInfo finderInfo;
+ uint16_t clumpSize;
+ HFSExtentRecord dataExtents; /**< Misaligned. */
+ HFSExtentRecord rsrcExtents; /**< Misaligned. */
+ uint32_t reserved; /**< Misaligned. */
+} HFSCatalogFile;
+#pragma pack()
+AssertCompileSize(HFSCatalogFile, 102);
+
+#pragma pack(1)
+typedef struct HFSPlusCatalogFile
+{
+ int16_t recordType;
+ uint16_t flags;
+ uint32_t reserved1;
+ uint32_t fileID;
+ uint32_t createDate;
+ uint32_t contentModDate;
+ uint32_t attributeModDate;
+ uint32_t accessDate;
+ uint32_t backupDate;
+ HFSPlusBSDInfo bsdInfo;
+ FndrFileInfo userInfo;
+ FndrOpaqueInfo finderInfo;
+ uint32_t textEncoding;
+ uint32_t reserved2;
+ HFSPlusForkData dataFork;
+ HFSPlusForkData resourceFork;
+} HFSPlusCatalogFile;
+#pragma pack()
+AssertCompileMemberAlignment(HFSPlusCatalogFile, dataFork, 8);
+AssertCompileSize(HFSPlusCatalogFile, 248);
+
+#pragma pack(1)
+typedef struct HFSCatalogThread
+{
+ int16_t recordType;
+ int32_t reserved[2];
+ uint32_t parentID;
+ uint8_t nodeName[kHFSMaxFileNameChars + 1];
+} HFSCatalogThread;
+#pragma pack()
+AssertCompileSize(HFSCatalogThread, 46);
+
+typedef struct HFSPlusCatalogThread
+{
+ int16_t recordType;
+ int16_t reserved;
+ uint32_t parentID;
+ HFSUniStr255 nodeName;
+} HFSPlusCatalogThread;
+AssertCompileSize(HFSPlusCatalogThread, 0x208);
+
+typedef struct HFSPlusAttrForkData
+{
+ uint32_t recordType;
+ uint32_t reserved;
+ HFSPlusForkData theFork;
+} HFSPlusAttrForkData;
+AssertCompileSize(HFSPlusAttrForkData, 88);
+
+typedef struct HFSPlusAttrExtents
+{
+ uint32_t recordType;
+ uint32_t reserved;
+ HFSPlusExtentRecord extents;
+} HFSPlusAttrExtents;
+AssertCompileSize(HFSPlusAttrExtents, 72);
+
+#pragma pack(1)
+typedef struct HFSPlusAttrData
+{
+ uint32_t recordType;
+ uint32_t reserved[2];
+ uint32_t attrSize;
+ uint8_t attrData[2]; /**< Causes misaligned struct size. */
+} HFSPlusAttrData;
+#pragma pack()
+AssertCompileSize(HFSPlusAttrData, 18);
+
+#pragma pack(1)
+typedef struct HFSPlusAttrInlineData
+{
+ uint32_t recordType;
+ uint32_t reserved;
+ uint32_t logicalSize;
+ uint8_t userData[2]; /**< Causes misaligned struct size. */
+} HFSPlusAttrInlineData;
+#pragma pack()
+AssertCompileSize(HFSPlusAttrInlineData, 14);
+
+typedef union HFSPlusAttrRecord
+{
+ uint32_t recordType;
+ HFSPlusAttrInlineData inlineData;
+ HFSPlusAttrData attrData;
+ HFSPlusAttrForkData forkData;
+ HFSPlusAttrExtents overflowExtents;
+} HFSPlusAttrRecord;
+AssertCompileSize(HFSPlusAttrRecord, 88);
+
+typedef struct HFSPlusAttrKey
+{
+ uint16_t keyLength;
+ uint16_t pad;
+ uint32_t fileID;
+ uint32_t startBlock;
+ uint16_t attrNameLen;
+ RTUTF16 attrName[kHFSMaxAttrNameLen];
+} HFSPlusAttrKey;
+AssertCompileSize(HFSPlusAttrKey, 268);
+
+#pragma pack(1)
+typedef struct HFSMasterDirectoryBlock
+{
+ uint16_t drSigWord;
+ uint32_t drCrDate; /**< Misaligned. */
+ uint32_t drLsMod; /**< Misaligned. */
+ uint16_t drAtrb;
+ uint16_t drNmFls;
+ uint16_t drVBMSt;
+ uint16_t drAllocPtr;
+ uint16_t drNmAlBlks;
+ uint32_t drAlBlkSiz;
+ uint32_t drClpSiz;
+ uint16_t drAlBlSt;
+ uint32_t drNxCNID; /**< Misaligned. */
+ uint16_t drFreeBks;
+ uint8_t drVN[kHFSMaxVolumeNameChars + 1];
+ uint32_t drVolBkUp;
+ uint16_t drVSeqNum;
+ uint32_t drWrCnt; /**< Misaligned. */
+ uint32_t drXTClpSiz; /**< Misaligned. */
+ uint32_t drCTClpSiz; /**< Misaligned. */
+ uint16_t drNmRtDirs;
+ uint32_t drFilCnt;
+ uint32_t drDirCnt;
+ uint32_t drFndrInfo[8];
+ uint16_t drEmbedSigWord;
+ HFSExtentDescriptor drEmbedExtent;
+ uint32_t drXTFlSize; /**< Misaligned. */
+ HFSExtentRecord drXTExtRec;
+ uint32_t drCTFlSize; /**< Misaligned. */
+ HFSExtentRecord drCTExtRec;
+} HFSMasterDirectoryBlock;
+#pragma pack()
+AssertCompileSize(HFSMasterDirectoryBlock, 162);
+
+typedef struct HFSPlusVolumeHeader
+{
+ uint16_t signature;
+ uint16_t version;
+ uint32_t attributes;
+ uint32_t lastMountedVersion;
+ uint32_t journalInfoBlock;
+ uint32_t createDate;
+ uint32_t modifyDate;
+ uint32_t backupDate;
+ uint32_t checkedDate;
+ uint32_t fileCount;
+ uint32_t folderCount;
+ uint32_t blockSize;
+ uint32_t totalBlocks;
+ uint32_t freeBlocks;
+ uint32_t nextAllocation;
+ uint32_t rsrcClumpSize;
+ uint32_t dataClumpSize;
+ uint32_t nextCatalogID;
+ uint32_t writeCount;
+ uint64_t encodingsBitmap;
+ uint8_t finderInfo[32];
+ HFSPlusForkData allocationFile;
+ HFSPlusForkData extentsFile;
+ HFSPlusForkData catalogFile;
+ HFSPlusForkData attributesFile;
+ HFSPlusForkData startupFile;
+} HFSPlusVolumeHeader;
+AssertCompileMemberAlignment(HFSPlusVolumeHeader, nextCatalogID, 8);
+AssertCompileSize(HFSPlusVolumeHeader, 512);
+
+typedef union BTreeKey
+{
+ uint8_t length8;
+ uint16_t length16;
+ uint8_t rawData[kMaxKeyLength + 2];
+} BTreeKey;
+AssertCompileSize(BTreeKey, 522);
+
+#pragma pack(1)
+typedef struct BTNodeDescriptor
+{
+ uint32_t fLink;
+ uint32_t bLink;
+ int8_t kind;
+ uint8_t height;
+ uint16_t numRecords;
+ uint16_t reserved; /**< Causes struct size misalignment. */
+} BTNodeDescriptor;
+#pragma pack()
+AssertCompileSize(BTNodeDescriptor, 14);
+
+#pragma pack(1)
+typedef struct BTHeaderRec
+{
+ uint16_t treeDepth;
+ uint32_t rootNode; /**< Misaligned. */
+ uint32_t leafRecords; /**< Misaligned. */
+ uint32_t firstLeafNode; /**< Misaligned. */
+ uint32_t lastLeafNode; /**< Misaligned. */
+ uint16_t nodeSize;
+ uint16_t maxKeyLength;
+ uint32_t totalNodes; /**< Misaligned. */
+ uint32_t freeNodes; /**< Misaligned. */
+ uint16_t reserved1;
+ uint32_t clumpSize;
+ uint8_t btreeType;
+ uint8_t keyCompareType;
+ uint32_t attributes; /**< Misaligned. */
+ uint32_t reserved3[16]; /**< Misaligned. */
+} BTHeaderRec;
+#pragma pack()
+AssertCompileSize(BTHeaderRec, 106);
+
+#pragma pack(1)
+typedef struct JournalInfoBlock
+{
+ uint32_t flags;
+ uint32_t devices_signature[8];
+ uint64_t offset; /**< Misaligned (morons). */
+ uint64_t size; /**< Misaligned. */
+ char ext_jnl_uuid[37];
+ char machine_serial_num[48];
+ char reserved[JIB_RESERVED_SIZE];
+} JournalInfoBlock;
+#pragma pack()
+AssertCompileSize(JournalInfoBlock, 180);
+
+/** @} */
+
+#endif
+
diff --git a/include/iprt/formats/mach-o.h b/include/iprt/formats/mach-o.h
new file mode 100644
index 00000000..6f51c8d3
--- /dev/null
+++ b/include/iprt/formats/mach-o.h
@@ -0,0 +1,626 @@
+/* $Id: mach-o.h $ */
+/** @file
+ * IPRT - Mach-O Structures and Constants.
+ */
+
+/*
+ * Copyright (C) 2011-2012 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.
+ */
+
+#ifndef ___internal_ldrMach_O_h
+#define ___internal_ldrMach_O_h
+
+#include <iprt/types.h>
+
+#ifndef CPU_ARCH_MASK
+
+/* cputype */
+#define CPU_ARCH_MASK INT32_C(0xff000000)
+#define CPU_ARCH_ABI64 INT32_C(0x01000000)
+#define CPU_TYPE_ANY INT32_C(-1)
+#define CPU_TYPE_VAX INT32_C(1)
+#define CPU_TYPE_MC680x0 INT32_C(6)
+#define CPU_TYPE_X86 INT32_C(7)
+#define CPU_TYPE_I386 CPU_TYPE_X86
+#define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64)
+#define CPU_TYPE_MC98000 INT32_C(10)
+#define CPU_TYPE_HPPA INT32_C(11)
+#define CPU_TYPE_MC88000 INT32_C(13)
+#define CPU_TYPE_SPARC INT32_C(14)
+#define CPU_TYPE_I860 INT32_C(15)
+#define CPU_TYPE_POWERPC INT32_C(18)
+#define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
+
+/* cpusubtype */
+#define CPU_SUBTYPE_MULTIPLE INT32_C(-1)
+#define CPU_SUBTYPE_LITTLE_ENDIAN INT32_C(0)
+#define CPU_SUBTYPE_BIG_ENDIAN INT32_C(1)
+
+#define CPU_SUBTYPE_VAX_ALL INT32_C(0)
+#define CPU_SUBTYPE_VAX780 INT32_C(1)
+#define CPU_SUBTYPE_VAX785 INT32_C(2)
+#define CPU_SUBTYPE_VAX750 INT32_C(3)
+#define CPU_SUBTYPE_VAX730 INT32_C(4)
+#define CPU_SUBTYPE_UVAXI INT32_C(5)
+#define CPU_SUBTYPE_UVAXII INT32_C(6)
+#define CPU_SUBTYPE_VAX8200 INT32_C(7)
+#define CPU_SUBTYPE_VAX8500 INT32_C(8)
+#define CPU_SUBTYPE_VAX8600 INT32_C(9)
+#define CPU_SUBTYPE_VAX8650 INT32_C(10)
+#define CPU_SUBTYPE_VAX8800 INT32_C(11)
+#define CPU_SUBTYPE_UVAXIII INT32_C(12)
+
+#define CPU_SUBTYPE_MC680x0_ALL INT32_C(1)
+#define CPU_SUBTYPE_MC68030 INT32_C(1)
+#define CPU_SUBTYPE_MC68040 INT32_C(2)
+#define CPU_SUBTYPE_MC68030_ONLY INT32_C(3)
+
+#define CPU_SUBTYPE_INTEL(fam, model) ( (int32_t )(((model) << 4) | (fam)) )
+#define CPU_SUBTYPE_INTEL_FAMILY(subtype) ( (subtype) & 0xf )
+#define CPU_SUBTYPE_INTEL_MODEL(subtype) ( (subtype) >> 4 )
+#define CPU_SUBTYPE_INTEL_FAMILY_MAX 0xf
+#define CPU_SUBTYPE_INTEL_MODEL_ALL 0
+
+#define CPU_SUBTYPE_I386_ALL CPU_SUBTYPE_INTEL(3, 0)
+#define CPU_SUBTYPE_386 CPU_SUBTYPE_INTEL(3, 0)
+#define CPU_SUBTYPE_486 CPU_SUBTYPE_INTEL(4, 0)
+#define CPU_SUBTYPE_486SX CPU_SUBTYPE_INTEL(4, 8)
+#define CPU_SUBTYPE_586 CPU_SUBTYPE_INTEL(5, 0)
+#define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0)
+#define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1)
+#define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3)
+#define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5)
+#define CPU_SUBTYPE_CELERON CPU_SUBTYPE_INTEL(7, 6)
+#define CPU_SUBTYPE_CELERON_MOBILE CPU_SUBTYPE_INTEL(7, 7)
+#define CPU_SUBTYPE_PENTIUM_3 CPU_SUBTYPE_INTEL(8, 0)
+#define CPU_SUBTYPE_PENTIUM_3_M CPU_SUBTYPE_INTEL(8, 1)
+#define CPU_SUBTYPE_PENTIUM_3_XEON CPU_SUBTYPE_INTEL(8, 2)
+#define CPU_SUBTYPE_PENTIUM_M CPU_SUBTYPE_INTEL(9, 0)
+#define CPU_SUBTYPE_PENTIUM_4 CPU_SUBTYPE_INTEL(10, 0)
+#define CPU_SUBTYPE_PENTIUM_4_M CPU_SUBTYPE_INTEL(10, 1)
+#define CPU_SUBTYPE_ITANIUM CPU_SUBTYPE_INTEL(11, 0)
+#define CPU_SUBTYPE_ITANIUM_2 CPU_SUBTYPE_INTEL(11, 1)
+#define CPU_SUBTYPE_XEON CPU_SUBTYPE_INTEL(12, 0)
+#define CPU_SUBTYPE_XEON_MP CPU_SUBTYPE_INTEL(12, 1)
+
+#define CPU_SUBTYPE_X86_ALL INT32_C(3)
+#define CPU_SUBTYPE_X86_64_ALL INT32_C(3)
+#define CPU_SUBTYPE_X86_ARCH1 INT32_C(4)
+
+#define CPU_SUBTYPE_MIPS_ALL INT32_C(0)
+#define CPU_SUBTYPE_MIPS_R2300 INT32_C(1)
+#define CPU_SUBTYPE_MIPS_R2600 INT32_C(2)
+#define CPU_SUBTYPE_MIPS_R2800 INT32_C(3)
+#define CPU_SUBTYPE_MIPS_R2000a INT32_C(4)
+#define CPU_SUBTYPE_MIPS_R2000 INT32_C(5)
+#define CPU_SUBTYPE_MIPS_R3000a INT32_C(6)
+#define CPU_SUBTYPE_MIPS_R3000 INT32_C(7)
+
+#define CPU_SUBTYPE_MC98000_ALL INT32_C(0)
+#define CPU_SUBTYPE_MC98601 INT32_C(1)
+
+#define CPU_SUBTYPE_HPPA_ALL INT32_C(0)
+#define CPU_SUBTYPE_HPPA_7100 INT32_C(0)
+#define CPU_SUBTYPE_HPPA_7100LC INT32_C(1)
+
+#define CPU_SUBTYPE_MC88000_ALL INT32_C(0)
+#define CPU_SUBTYPE_MC88100 INT32_C(1)
+#define CPU_SUBTYPE_MC88110 INT32_C(2)
+
+#define CPU_SUBTYPE_SPARC_ALL INT32_C(0)
+
+#define CPU_SUBTYPE_I860_ALL INT32_C(0)
+#define CPU_SUBTYPE_I860_860 INT32_C(1)
+
+#define CPU_SUBTYPE_POWERPC_ALL INT32_C(0)
+#define CPU_SUBTYPE_POWERPC_601 INT32_C(1)
+#define CPU_SUBTYPE_POWERPC_602 INT32_C(2)
+#define CPU_SUBTYPE_POWERPC_603 INT32_C(3)
+#define CPU_SUBTYPE_POWERPC_603e INT32_C(4)
+#define CPU_SUBTYPE_POWERPC_603ev INT32_C(5)
+#define CPU_SUBTYPE_POWERPC_604 INT32_C(6)
+#define CPU_SUBTYPE_POWERPC_604e INT32_C(7)
+#define CPU_SUBTYPE_POWERPC_620 INT32_C(8)
+#define CPU_SUBTYPE_POWERPC_750 INT32_C(9)
+#define CPU_SUBTYPE_POWERPC_7400 INT32_C(10)
+#define CPU_SUBTYPE_POWERPC_7450 INT32_C(11)
+#define CPU_SUBTYPE_POWERPC_Max INT32_C(10)
+#define CPU_SUBTYPE_POWERPC_SCVger INT32_C(11)
+#define CPU_SUBTYPE_POWERPC_970 INT32_C(100)
+
+#define CPU_SUBTYPE_MASK UINT32_C(0xff000000)
+#define CPU_SUBTYPE_LIB64 UINT32_C(0x80000000)
+
+#endif /* !CPU_ARCH_MASK */
+
+
+typedef struct fat_header
+{
+ uint32_t magic;
+ uint32_t nfat_arch;
+} fat_header_t;
+
+#ifndef IMAGE_FAT_SIGNATURE
+# define IMAGE_FAT_SIGNATURE UINT32_C(0xcafebabe)
+#endif
+#ifndef IMAGE_FAT_SIGNATURE_OE
+# define IMAGE_FAT_SIGNATURE_OE UINT32_C(0xbebafeca)
+#endif
+
+typedef struct fat_arch
+{
+ int32_t cputype;
+ int32_t cpusubtype;
+ uint32_t offset;
+ uint32_t size;
+ uint32_t align;
+} fat_arch_t;
+
+typedef struct mach_header_32
+{
+ uint32_t magic;
+ int32_t cputype;
+ int32_t cpusubtype;
+ uint32_t filetype;
+ uint32_t ncmds;
+ uint32_t sizeofcmds;
+ uint32_t flags;
+} mach_header_32_t;
+
+/* magic */
+#ifndef IMAGE_MACHO32_SIGNATURE
+# define IMAGE_MACHO32_SIGNATURE UINT32_C(0xfeedface)
+#endif
+#ifndef IMAGE_MACHO32_SIGNATURE_OE
+# define IMAGE_MACHO32_SIGNATURE_OE UINT32_C(0xcefaedfe)
+#endif
+#define MH_MAGIC IMAGE_MACHO32_SIGNATURE
+#define MH_CIGAM IMAGE_MACHO32_SIGNATURE_OE
+
+typedef struct mach_header_64
+{
+ uint32_t magic;
+ int32_t cputype;
+ int32_t cpusubtype;
+ uint32_t filetype;
+ uint32_t ncmds;
+ uint32_t sizeofcmds;
+ uint32_t flags;
+ uint32_t reserved;
+} mach_header_64_t;
+
+/* magic */
+#ifndef IMAGE_MACHO64_SIGNATURE
+# define IMAGE_MACHO64_SIGNATURE UINT32_C(0xfeedfacf)
+#endif
+#ifndef IMAGE_MACHO64_SIGNATURE_OE
+# define IMAGE_MACHO64_SIGNATURE_OE UINT32_C(0xfefaedfe)
+#endif
+#define MH_MAGIC_64 IMAGE_MACHO64_SIGNATURE
+#define MH_CIGAM_64 IMAGE_MACHO64_SIGNATURE_OE
+
+/* mach_header_* filetype */
+#define MH_OBJECT UINT32_C(1)
+#define MH_EXECUTE UINT32_C(2)
+#define MH_FVMLIB UINT32_C(3)
+#define MH_CORE UINT32_C(4)
+#define MH_PRELOAD UINT32_C(5)
+#define MH_DYLIB UINT32_C(6)
+#define MH_DYLINKER UINT32_C(7)
+#define MH_BUNDLE UINT32_C(8)
+#define MH_DYLIB_STUB UINT32_C(9)
+#define MH_DSYM UINT32_C(10)
+#define MH_KEXT_BUNDLE UINT32_C(11)
+
+/* mach_header_* flags */
+#define MH_NOUNDEFS UINT32_C(0x00000001)
+#define MH_INCRLINK UINT32_C(0x00000002)
+#define MH_DYLDLINK UINT32_C(0x00000004)
+#define MH_BINDATLOAD UINT32_C(0x00000008)
+#define MH_PREBOUND UINT32_C(0x00000010)
+#define MH_SPLIT_SEGS UINT32_C(0x00000020)
+#define MH_LAZY_INIT UINT32_C(0x00000040)
+#define MH_TWOLEVEL UINT32_C(0x00000080)
+#define MH_FORCE_FLAT UINT32_C(0x00000100)
+#define MH_NOMULTIDEFS UINT32_C(0x00000200)
+#define MH_NOFIXPREBINDING UINT32_C(0x00000400)
+#define MH_PREBINDABLE UINT32_C(0x00000800)
+#define MH_ALLMODSBOUND UINT32_C(0x00001000)
+#define MH_SUBSECTIONS_VIA_SYMBOLS UINT32_C(0x00002000)
+#define MH_CANONICAL UINT32_C(0x00004000)
+#define MH_WEAK_DEFINES UINT32_C(0x00008000)
+#define MH_BINDS_TO_WEAK UINT32_C(0x00010000)
+#define MH_ALLOW_STACK_EXECUTION UINT32_C(0x00020000)
+#define MH_ROOT_SAFE UINT32_C(0x00040000)
+#define MH_SETUID_SAFE UINT32_C(0x00080000)
+#define MH_NO_REEXPORTED_DYLIBS UINT32_C(0x00100000)
+#define MH_PIE UINT32_C(0x00200000)
+#define MH_DEAD_STRIPPABLE_DYLIB UINT32_C(0x00400000)
+#define MH_HAS_TLV_DESCRIPTORS UINT32_C(0x00800000)
+#define MH_NO_HEAP_EXECUTION UINT32_C(0x01000000)
+#define MH_VALID_FLAGS UINT32_C(0x01ffffff)
+
+
+typedef struct load_command
+{
+ uint32_t cmd;
+ uint32_t cmdsize;
+} load_command_t;
+
+/* load cmd */
+#define LC_REQ_DYLD UINT32_C(0x80000000)
+#define LC_SEGMENT_32 UINT32_C(0x01)
+#define LC_SYMTAB UINT32_C(0x02)
+#define LC_SYMSEG UINT32_C(0x03)
+#define LC_THREAD UINT32_C(0x04)
+#define LC_UNIXTHREAD UINT32_C(0x05)
+#define LC_LOADFVMLIB UINT32_C(0x06)
+#define LC_IDFVMLIB UINT32_C(0x07)
+#define LC_IDENT UINT32_C(0x08)
+#define LC_FVMFILE UINT32_C(0x09)
+#define LC_PREPAGE UINT32_C(0x0a)
+#define LC_DYSYMTAB UINT32_C(0x0b)
+#define LC_LOAD_DYLIB UINT32_C(0x0c)
+#define LC_ID_DYLIB UINT32_C(0x0d)
+#define LC_LOAD_DYLINKER UINT32_C(0x0e)
+#define LC_ID_DYLINKER UINT32_C(0x0f)
+#define LC_PREBOUND_DYLIB UINT32_C(0x10)
+#define LC_ROUTINES UINT32_C(0x11)
+#define LC_SUB_FRAMEWORK UINT32_C(0x12)
+#define LC_SUB_UMBRELLA UINT32_C(0x13)
+#define LC_SUB_CLIENT UINT32_C(0x14)
+#define LC_SUB_LIBRARY UINT32_C(0x15)
+#define LC_TWOLEVEL_HINTS UINT32_C(0x16)
+#define LC_PREBIND_CKSUM UINT32_C(0x17)
+#define LC_LOAD_WEAK_DYLIB (UINT32_C(0x18) | LC_REQ_DYLD)
+#define LC_SEGMENT_64 UINT32_C(0x19)
+#define LC_ROUTINES_64 UINT32_C(0x1a)
+#define LC_UUID UINT32_C(0x1b)
+#define LC_RPATH (UINT32_C(0x1c) | LC_REQ_DYLD)
+#define LC_CODE_SIGNATURE UINT32_C(0x1d)
+#define LC_SEGMENT_SPLIT_INFO UINT32_C(0x1e)
+#define LC_REEXPORT_DYLIB (UINT32_C(0x1f) | LC_REQ_DYLD)
+#define LC_LAZY_LOAD_DYLIB UINT32_C(0x20)
+#define LC_ENCRYPTION_INFO UINT32_C(0x21)
+#define LC_DYLD_INFO UINT32_C(0x22)
+#define LC_DYLD_INFO_ONLY (UINT32_C(0x22) | LC_REQ_DYLD)
+#define LC_LOAD_UPWARD_DYLIB (UINT32_C(0x23) | LC_REQ_DYLD)
+#define LC_VERSION_MIN_MACOSX UINT32_C(0x24)
+#define LC_VERSION_MIN_IPHONEOS UINT32_C(0x25)
+#define LC_FUNCTION_STARTS UINT32_C(0x26)
+#define LC_DYLD_ENVIRONMENT UINT32_C(0x27)
+#define LC_MAIN (UINT32_C(0x28) | LC_REQ_DYLD)
+#define LC_DATA_IN_CODE UINT32_C(0x29)
+#define LC_SOURCE_VERSION UINT32_C(0x2a)
+#define LC_DYLIB_CODE_SIGN_DRS UINT32_C(0x2b)
+
+
+typedef struct lc_str
+{
+ uint32_t offset;
+} lc_str_t;
+
+typedef struct segment_command_32
+{
+ uint32_t cmd;
+ uint32_t cmdsize;
+ char segname[16];
+ uint32_t vmaddr;
+ uint32_t vmsize;
+ uint32_t fileoff;
+ uint32_t filesize;
+ uint32_t maxprot;
+ uint32_t initprot;
+ uint32_t nsects;
+ uint32_t flags;
+} segment_command_32_t;
+
+typedef struct segment_command_64
+{
+ uint32_t cmd;
+ uint32_t cmdsize;
+ char segname[16];
+ uint64_t vmaddr;
+ uint64_t vmsize;
+ uint64_t fileoff;
+ uint64_t filesize;
+ uint32_t maxprot;
+ uint32_t initprot;
+ uint32_t nsects;
+ uint32_t flags;
+} segment_command_64_t;
+
+/* segment flags */
+#define SG_HIGHVM UINT32_C(0x00000001)
+#define SG_FVMLIB UINT32_C(0x00000002)
+#define SG_NORELOC UINT32_C(0x00000004)
+#define SG_PROTECTED_VERSION_1 UINT32_C(0x00000008)
+
+/* maxprot/initprot */
+#ifndef VM_PROT_NONE
+# define VM_PROT_NONE UINT32_C(0x00000000)
+# define VM_PROT_READ UINT32_C(0x00000001)
+# define VM_PROT_WRITE UINT32_C(0x00000002)
+# define VM_PROT_EXECUTE UINT32_C(0x00000004)
+# define VM_PROT_ALL UINT32_C(0x00000007)
+#endif
+
+typedef struct section_32
+{
+ char sectname[16];
+ char segname[16];
+ uint32_t addr;
+ uint32_t size;
+ uint32_t offset;
+ uint32_t align;
+ uint32_t reloff;
+ uint32_t nreloc;
+ uint32_t flags;
+ uint32_t reserved1;
+ uint32_t reserved2;
+} section_32_t;
+
+typedef struct section_64
+{
+ char sectname[16];
+ char segname[16];
+ uint64_t addr;
+ uint64_t size;
+ uint32_t offset;
+ uint32_t align;
+ uint32_t reloff;
+ uint32_t nreloc;
+ uint32_t flags;
+ uint32_t reserved1;
+ uint32_t reserved2;
+ uint32_t reserved3;
+} section_64_t;
+
+/* section flags */
+#define SECTION_TYPE UINT32_C(0x000000ff)
+#define S_REGULAR 0x0
+#define S_ZEROFILL 0x1
+#define S_CSTRING_LITERALS 0x2
+#define S_4BYTE_LITERALS 0x3
+#define S_8BYTE_LITERALS 0x4
+#define S_LITERAL_POINTERS 0x5
+#define S_NON_LAZY_SYMBOL_POINTERS 0x6
+#define S_LAZY_SYMBOL_POINTERS 0x7
+#define S_SYMBOL_STUBS 0x8
+#define S_MOD_INIT_FUNC_POINTERS 0x9
+#define S_MOD_TERM_FUNC_POINTERS 0xa
+#define S_COALESCED 0xb
+#define S_GB_ZEROFILL 0xc
+#define S_INTERPOSING 0xd
+#define S_16BYTE_LITERALS 0xe
+#define S_DTRACE_DOF 0xf
+#define S_LAZY_DYLIB_SYMBOL_POINTERS 0x10
+
+#define SECTION_ATTRIBUTES UINT32_C(0xffffff00)
+#define SECTION_ATTRIBUTES_USR UINT32_C(0xff000000)
+#define S_ATTR_PURE_INSTRUCTIONS UINT32_C(0x80000000)
+#define S_ATTR_NO_TOC UINT32_C(0x40000000)
+#define S_ATTR_STRIP_STATIC_SYMS UINT32_C(0x20000000)
+#define S_ATTR_NO_DEAD_STRIP UINT32_C(0x10000000)
+#define S_ATTR_LIVE_SUPPORT UINT32_C(0x08000000)
+#define S_ATTR_SELF_MODIFYING_CODE UINT32_C(0x04000000)
+#define S_ATTR_DEBUG UINT32_C(0x02000000)
+#define SECTION_ATTRIBUTES_SYS UINT32_C(0x00ffff00)
+#define S_ATTR_SOME_INSTRUCTIONS UINT32_C(0x00000400)
+#define S_ATTR_EXT_RELOC UINT32_C(0x00000200)
+#define S_ATTR_LOC_RELOC UINT32_C(0x00000100)
+
+/* standard section names */
+#define SEG_PAGEZERO "__PAGEZERO"
+#define SEG_TEXT "__TEXT"
+#define SECT_TEXT "__text"
+#define SECT_FVMLIB_INIT0 "__fvmlib_init0"
+#define SECT_FVMLIB_INIT1 "__fvmlib_init1"
+#define SEG_DATA "__DATA"
+#define SECT_DATA "__data"
+#define SECT_BSS "__bss"
+#define SECT_COMMON "__common"
+#define SEG_OBJC "__OBJC"
+#define SECT_OBJC_SYMBOLS "__symbol_table"
+#define SECT_OBJC_MODULES "__module_info"
+#define SECT_OBJC_STRINGS "__selector_strs"
+#define SECT_OBJC_REFS "__selector_refs"
+#define SEG_ICON "__ICON"
+#define SECT_ICON_HEADER "__header"
+#define SECT_ICON_TIFF "__tiff"
+#define SEG_LINKEDIT "__LINKEDIT"
+#define SEG_UNIXSTACK "__UNIXSTACK"
+#define SEG_IMPORT "__IMPORT"
+
+typedef struct thread_command
+{
+ uint32_t cmd;
+ uint32_t cmdsize;
+} thread_command_t;
+
+typedef struct symtab_command
+{
+ uint32_t cmd;
+ uint32_t cmdsize;
+ uint32_t symoff;
+ uint32_t nsyms;
+ uint32_t stroff;
+ uint32_t strsize;
+} symtab_command_t;
+
+typedef struct uuid_command
+{
+ uint32_t cmd;
+ uint32_t cmdsize;
+ uint8_t uuid[16];
+} uuid_command_t;
+
+typedef struct macho_nlist_32
+{
+ union
+ {
+ int32_t n_strx;
+ } n_un;
+ uint8_t n_type;
+ uint8_t n_sect;
+ int16_t n_desc;
+ uint32_t n_value;
+} macho_nlist_32_t;
+
+
+typedef struct macho_nlist_64
+{
+ union
+ {
+ uint32_t n_strx;
+ } n_un;
+ uint8_t n_type;
+ uint8_t n_sect;
+ int16_t n_desc;
+ uint64_t n_value;
+} macho_nlist_64_t;
+
+#define MACHO_N_EXT UINT8_C(0x01)
+#define MACHO_N_PEXT UINT8_C(0x10)
+
+#define MACHO_N_TYPE UINT8_C(0x0e)
+#define MACHO_N_UNDF UINT8_C(0x00)
+#define MACHO_N_ABS UINT8_C(0x02)
+#define MACHO_N_INDR UINT8_C(0x0a)
+#define MACHO_N_PBUD UINT8_C(0x0c)
+#define MACHO_N_SECT UINT8_C(0x0e)
+
+#define MACHO_N_STAB UINT8_C(0xe0)
+#define MACHO_N_GSYM UINT8_C(0x20)
+#define MACHO_N_FNAME UINT8_C(0x22)
+#define MACHO_N_FUN UINT8_C(0x24)
+#define MACHO_N_STSYM UINT8_C(0x26)
+#define MACHO_N_LCSYM UINT8_C(0x28)
+#define MACHO_N_BNSYM UINT8_C(0x2e)
+#define MACHO_N_PC UINT8_C(0x30)
+#define MACHO_N_OPT UINT8_C(0x3c)
+#define MACHO_N_RSYM UINT8_C(0x40)
+#define MACHO_N_SLINE UINT8_C(0x44)
+#define MACHO_N_ENSYM UINT8_C(0x4e)
+#define MACHO_N_SSYM UINT8_C(0x60)
+#define MACHO_N_SO UINT8_C(0x64)
+#define MACHO_N_OSO UINT8_C(0x66)
+#define MACHO_N_LSYM UINT8_C(0x80)
+#define MACHO_N_BINCL UINT8_C(0x82)
+#define MACHO_N_SOL UINT8_C(0x84)
+#define MACHO_N_PARAMS UINT8_C(0x86)
+#define MACHO_N_VERSION UINT8_C(0x88)
+#define MACHO_N_OLEVEL UINT8_C(0x8A)
+#define MACHO_N_PSYM UINT8_C(0xa0)
+#define MACHO_N_EINCL UINT8_C(0xa2)
+#define MACHO_N_ENTRY UINT8_C(0xa4)
+#define MACHO_N_LBRAC UINT8_C(0xc0)
+#define MACHO_N_EXCL UINT8_C(0xc2)
+#define MACHO_N_RBRAC UINT8_C(0xe0)
+#define MACHO_N_BCOMM UINT8_C(0xe2)
+#define MACHO_N_ECOMM UINT8_C(0xe4)
+#define MACHO_N_ECOML UINT8_C(0xe8)
+#define MACHO_N_LENG UINT8_C(0xfe)
+
+#define MACHO_NO_SECT UINT8_C(0x00)
+#define MACHO_MAX_SECT UINT8_C(0xff)
+
+#define REFERENCE_TYPE UINT16_C(0x000f)
+#define REFERENCE_FLAG_UNDEFINED_NON_LAZY 0
+#define REFERENCE_FLAG_UNDEFINED_LAZY 1
+#define REFERENCE_FLAG_DEFINED 2
+#define REFERENCE_FLAG_PRIVATE_DEFINED 3
+#define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY 4
+#define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY 5
+#define REFERENCED_DYNAMICALLY UINT16_C(0x0010)
+
+#define GET_LIBRARY_ORDINAL(a_n_desc) \
+ RT_BYTE2(a_n_desc)
+#define SET_LIBRARY_ORDINAL(a_n_desc, a_ordinal) \
+ do { (a_n_desc) = RT_MAKE_U16(RT_BYTE1(a_n_desc), a_ordinal); } while (0)
+
+#define SELF_LIBRARY_ORDINAL 0x00
+#define MAX_LIBRARY_ORDINAL 0xfd
+#define DYNAMIC_LOOKUP_ORDINAL 0xfe
+#define EXECUTABLE_ORDINAL 0xff
+
+#define N_NO_DEAD_STRIP UINT16_C(0x0020)
+#define N_DESC_DISCARDED UINT16_C(0x0020)
+#define N_WEAK_REF UINT16_C(0x0040)
+#define N_WEAK_DEF UINT16_C(0x0080)
+#define N_REF_TO_WEAK UINT16_C(0x0080)
+
+typedef struct macho_relocation_info
+{
+ int32_t r_address;
+ uint32_t r_symbolnum : 24;
+ uint32_t r_pcrel : 1;
+ uint32_t r_length : 2;
+ uint32_t r_extern : 1;
+ uint32_t r_type : 4;
+} macho_relocation_info_t;
+
+#define R_ABS 0
+#define R_SCATTERED UINT32_C(0x80000000)
+
+typedef struct scattered_relocation_info
+{
+#ifdef RT_LITTLE_ENDIAN
+ uint32_t r_address : 24;
+ uint32_t r_type : 4;
+ uint32_t r_length : 2;
+ uint32_t r_pcrel : 1;
+ uint32_t r_scattered : 1;
+#elif defined(RT_BIG_ENDIAN)
+ uint32_t r_scattered : 1;
+ uint32_t r_pcrel : 1;
+ uint32_t r_length : 2;
+ uint32_t r_type : 4;
+ uint32_t r_address : 24;
+#else
+# error "Neither K_ENDIAN isn't LITTLE or BIG!"
+#endif
+ int32_t r_value;
+} scattered_relocation_info_t;
+
+typedef enum reloc_type_generic
+{
+ GENERIC_RELOC_VANILLA = 0,
+ GENERIC_RELOC_PAIR,
+ GENERIC_RELOC_SECTDIFF,
+ GENERIC_RELOC_PB_LA_PTR,
+ GENERIC_RELOC_LOCAL_SECTDIFF
+} reloc_type_generic_t;
+
+typedef enum reloc_type_x86_64
+{
+ X86_64_RELOC_UNSIGNED = 0,
+ X86_64_RELOC_SIGNED,
+ X86_64_RELOC_BRANCH,
+ X86_64_RELOC_GOT_LOAD,
+ X86_64_RELOC_GOT,
+ X86_64_RELOC_SUBTRACTOR,
+ X86_64_RELOC_SIGNED_1,
+ X86_64_RELOC_SIGNED_2,
+ X86_64_RELOC_SIGNED_4
+} reloc_type_x86_64_t;
+
+#endif
+
diff --git a/include/iprt/formats/mz.mac b/include/iprt/formats/mz.mac
new file mode 100644
index 00000000..bdcd45f7
--- /dev/null
+++ b/include/iprt/formats/mz.mac
@@ -0,0 +1,56 @@
+;; @file
+; IPRT - MZ (DOS Executable Header) definitions for YASM/NASM.
+;
+
+;
+; Copyright (C) 2006-2013 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.
+;
+
+%ifndef ___iprt_formats_mz_mac
+%define ___iprt_formats_mz_mac
+
+struc IMAGE_DOS_HEADER
+ .e_magic resw 1
+ .e_cblp resw 1
+ .e_cp resw 1
+ .e_crlc resw 1
+ .e_cparhdr resw 1
+ .e_minalloc resw 1
+ .e_maxalloc resw 1
+ .e_ss resw 1
+ .e_sp resw 1
+ .e_csum resw 1
+ .e_ip resw 1
+ .e_cs resw 1
+ .e_lfarlc resw 1
+ .e_ovno resw 1
+ .e_res resw 4
+ .e_oemid resw 1
+ .e_oeminfo resw 1
+ .e_res2 resw 10
+ .e_lfanew resd 1
+endstruc
+
+%ifndef IMAGE_DOS_SIGNATURE
+ %define IMAGE_DOS_SIGNATURE 0x5a4d
+%endif
+
+%endif
+
diff --git a/include/iprt/formats/pe.mac b/include/iprt/formats/pe.mac
new file mode 100644
index 00000000..0d23ef54
--- /dev/null
+++ b/include/iprt/formats/pe.mac
@@ -0,0 +1,722 @@
+;; @file
+; IPRT - Windows PE definitions for YASM/NASM.
+;
+
+;
+; Copyright (C) 2006-2013 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.
+;
+
+%ifndef ___iprt_format_pe_mac
+%define ___iprt_format_pe_mac
+
+
+;*******************************************************************************
+;* Header Files *
+;*******************************************************************************
+%include "iprt/asmdefs.mac"
+
+
+;*******************************************************************************
+;* Defined Constants And Macros *
+;*******************************************************************************
+%define IMAGE_NT_SIGNATURE 0x00004550
+
+; file header
+%define IMAGE_FILE_MACHINE_I386 0x014c
+%define IMAGE_FILE_MACHINE_AMD64 0x8664
+
+%define IMAGE_FILE_RELOCS_STRIPPED 0x0001
+%define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002
+%define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004
+%define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008
+%define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010
+%define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020
+%define IMAGE_FILE_16BIT_MACHINE 0x0040
+%define IMAGE_FILE_BYTES_REVERSED_LO 0x0080
+%define IMAGE_FILE_32BIT_MACHINE 0x0100
+%define IMAGE_FILE_DEBUG_STRIPPED 0x0200
+%define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400
+%define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800
+%define IMAGE_FILE_SYSTEM 0x1000
+%define IMAGE_FILE_DLL 0x2000
+%define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000
+%define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
+
+
+; optional header
+%define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10B
+%define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20B
+
+%define IMAGE_SUBSYSTEM_UNKNOWN 0x0
+%define IMAGE_SUBSYSTEM_NATIVE 0x1
+%define IMAGE_SUBSYSTEM_WINDOWS_GUI 0x2
+%define IMAGE_SUBSYSTEM_WINDOWS_CUI 0x3
+%define IMAGE_SUBSYSTEM_OS2_GUI 0x4
+%define IMAGE_SUBSYSTEM_OS2_CUI 0x5
+%define IMAGE_SUBSYSTEM_POSIX_CUI 0x7
+
+%define IMAGE_LIBRARY_PROCESS_INIT 0x0001
+%define IMAGE_LIBRARY_PROCESS_TERM 0x0002
+%define IMAGE_LIBRARY_THREAD_INIT 0x0004
+%define IMAGE_LIBRARY_THREAD_TERM 0x0008
+%define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION 0x0200
+%define IMAGE_DLLCHARACTERISTICS_NO_SEH 0x0400
+%define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
+%define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
+%define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
+
+%define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 0x10
+
+%define IMAGE_DIRECTORY_ENTRY_EXPORT 0x0
+%define IMAGE_DIRECTORY_ENTRY_IMPORT 0x1
+%define IMAGE_DIRECTORY_ENTRY_RESOURCE 0x2
+%define IMAGE_DIRECTORY_ENTRY_EXCEPTION 0x3
+%define IMAGE_DIRECTORY_ENTRY_SECURITY 0x4
+%define IMAGE_DIRECTORY_ENTRY_BASERELOC 0x5
+%define IMAGE_DIRECTORY_ENTRY_DEBUG 0x6
+%define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 0x7
+%define IMAGE_DIRECTORY_ENTRY_COPYRIGHT IMAGE_DIRECTORY_ENTRY_ARCHITECTURE
+%define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 0x8
+%define IMAGE_DIRECTORY_ENTRY_TLS 0x9
+%define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 0xa
+%define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 0xb
+%define IMAGE_DIRECTORY_ENTRY_IAT 0xc
+%define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 0xd
+%define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 0xe
+
+
+; section header
+%define IMAGE_SIZEOF_SHORT_NAME 0x8
+
+%define IMAGE_SCN_TYPE_REG 0x00000000
+%define IMAGE_SCN_TYPE_DSECT 0x00000001
+%define IMAGE_SCN_TYPE_NOLOAD 0x00000002
+%define IMAGE_SCN_TYPE_GROUP 0x00000004
+%define IMAGE_SCN_TYPE_NO_PAD 0x00000008
+%define IMAGE_SCN_TYPE_COPY 0x00000010
+
+%define IMAGE_SCN_CNT_CODE 0x00000020
+%define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
+%define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
+
+%define IMAGE_SCN_LNK_OTHER 0x00000100
+%define IMAGE_SCN_LNK_INFO 0x00000200
+%define IMAGE_SCN_TYPE_OVER 0x00000400
+%define IMAGE_SCN_LNK_REMOVE 0x00000800
+%define IMAGE_SCN_LNK_COMDAT 0x00001000
+%define IMAGE_SCN_MEM_PROTECTED 0x00004000
+%define IMAGE_SCN_NO_DEFER_SPEC_EXC 0x00004000
+%define IMAGE_SCN_GPREL 0x00008000
+%define IMAGE_SCN_MEM_FARDATA 0x00008000
+%define IMAGE_SCN_MEM_SYSHEAP 0x00010000
+%define IMAGE_SCN_MEM_PURGEABLE 0x00020000
+%define IMAGE_SCN_MEM_16BIT 0x00020000
+%define IMAGE_SCN_MEM_LOCKED 0x00040000
+%define IMAGE_SCN_MEM_PRELOAD 0x00080000
+
+%define IMAGE_SCN_ALIGN_1BYTES 0x00100000
+%define IMAGE_SCN_ALIGN_2BYTES 0x00200000
+%define IMAGE_SCN_ALIGN_4BYTES 0x00300000
+%define IMAGE_SCN_ALIGN_8BYTES 0x00400000
+%define IMAGE_SCN_ALIGN_16BYTES 0x00500000
+%define IMAGE_SCN_ALIGN_32BYTES 0x00600000
+%define IMAGE_SCN_ALIGN_64BYTES 0x00700000
+%define IMAGE_SCN_ALIGN_128BYTES 0x00800000
+%define IMAGE_SCN_ALIGN_256BYTES 0x00900000
+%define IMAGE_SCN_ALIGN_512BYTES 0x00A00000
+%define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000
+%define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000
+%define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000
+%define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000
+%define IMAGE_SCN_ALIGN_MASK 0x00F00000
+%define IMAGE_SCN_ALIGN_SHIFT 20
+
+%define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
+%define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
+%define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
+%define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
+%define IMAGE_SCN_MEM_SHARED 0x10000000
+%define IMAGE_SCN_MEM_EXECUTE 0x20000000
+%define IMAGE_SCN_MEM_READ 0x40000000
+%define IMAGE_SCN_MEM_WRITE 0x80000000
+
+
+; relocations
+%define IMAGE_REL_BASED_ABSOLUTE 0x0
+%define IMAGE_REL_BASED_HIGH 0x1
+%define IMAGE_REL_BASED_LOW 0x2
+%define IMAGE_REL_BASED_HIGHLOW 0x3
+%define IMAGE_REL_BASED_HIGHADJ 0x4
+%define IMAGE_REL_BASED_MIPS_JMPADDR 0x5
+%define IMAGE_REL_BASED_MIPS_JMPADDR16 0x9
+%define IMAGE_REL_BASED_IA64_IMM64 0x9
+%define IMAGE_REL_BASED_DIR64 0xa
+%define IMAGE_REL_BASED_HIGH3ADJ 0xb
+
+
+; imports
+%define IMAGE_ORDINAL_FLAG32 0x80000000
+%define IMAGE_ORDINAL_FLAG64 UINT64_MAX(0x8000000000000000)
+
+
+; debug dir
+%define IMAGE_DEBUG_TYPE_UNKNOWN UINT32_C(0x0)
+%define IMAGE_DEBUG_TYPE_COFF UINT32_C(0x1)
+%define IMAGE_DEBUG_TYPE_CODEVIEW UINT32_C(0x2)
+%define IMAGE_DEBUG_TYPE_FPO UINT32_C(0x3)
+%define IMAGE_DEBUG_TYPE_MISC UINT32_C(0x4)
+%define IMAGE_DEBUG_TYPE_EXCEPTION UINT32_C(0x5)
+%define IMAGE_DEBUG_TYPE_FIXUP UINT32_C(0x6)
+%define IMAGE_DEBUG_TYPE_OMAP_TO_SRC UINT32_C(0x7)
+%define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC UINT32_C(0x8)
+%define IMAGE_DEBUG_TYPE_BORLAND UINT32_C(0x9)
+%define IMAGE_DEBUG_TYPE_RESERVED10 UINT32_C(0x10)
+
+%define IMAGE_DEBUG_MISC_EXENAME UINT32_C(1)
+
+; security directory
+%define WIN_CERT_REVISION_1_0 UINT16_C(0x0100)
+%define WIN_CERT_REVISION_2_0 UINT16_C(0x0200)
+
+%define WIN_CERT_TYPE_X509 UINT16_C(1)
+%define WIN_CERT_TYPE_PKCS_SIGNED_DATA UINT16_C(2)
+%define WIN_CERT_TYPE_RESERVED_1 UINT16_C(3)
+%define WIN_CERT_TYPE_TS_STACK_SIGNED UINT16_C(4)
+%define WIN_CERT_TYPE_EFI_PKCS115 UINT16_C(0x0ef0)
+%define WIN_CERT_TYPE_EFI_GUID UINT16_C(0x0ef1)
+
+
+; For .DBG files.
+%define IMAGE_SEPARATE_DEBUG_SIGNATURE UINT16_C(0x4944)
+
+%define IMAGE_SIZE_OF_SYMBOL 18
+%define IMAGE_SIZE_OF_SYMBOL_EX 20
+
+%define IMAGE_SYM_UNDEFINED INT16_C(0)
+%define IMAGE_SYM_ABSOLUTE INT16_C(-1)
+%define IMAGE_SYM_DEBUG INT16_C(-2)
+
+%define IMAGE_SYM_CLASS_END_OF_FUNCTION UINT8_C(0xff) ; -1
+%define IMAGE_SYM_CLASS_NULL UINT8_C(0)
+%define IMAGE_SYM_CLASS_AUTOMATIC UINT8_C(1)
+%define IMAGE_SYM_CLASS_EXTERNAL UINT8_C(2)
+%define IMAGE_SYM_CLASS_STATIC UINT8_C(3)
+%define IMAGE_SYM_CLASS_REGISTER UINT8_C(4)
+%define IMAGE_SYM_CLASS_EXTERNAL_DEF UINT8_C(5)
+%define IMAGE_SYM_CLASS_LABEL UINT8_C(6)
+%define IMAGE_SYM_CLASS_UNDEFINED_LABEL UINT8_C(7)
+%define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT UINT8_C(8)
+%define IMAGE_SYM_CLASS_ARGUMENT UINT8_C(9)
+%define IMAGE_SYM_CLASS_STRUCT_TAG UINT8_C(10)
+%define IMAGE_SYM_CLASS_MEMBER_OF_UNION UINT8_C(11)
+%define IMAGE_SYM_CLASS_UNION_TAG UINT8_C(12)
+%define IMAGE_SYM_CLASS_TYPE_DEFINITION UINT8_C(13)
+%define IMAGE_SYM_CLASS_UNDEFINED_STATIC UINT8_C(14)
+%define IMAGE_SYM_CLASS_ENUM_TAG UINT8_C(15)
+%define IMAGE_SYM_CLASS_MEMBER_OF_ENUM UINT8_C(16)
+%define IMAGE_SYM_CLASS_REGISTER_PARAM UINT8_C(17)
+%define IMAGE_SYM_CLASS_BIT_FIELD UINT8_C(18)
+%define IMAGE_SYM_CLASS_FAR_EXTERNAL UINT8_C(68)
+%define IMAGE_SYM_CLASS_BLOCK UINT8_C(100)
+%define IMAGE_SYM_CLASS_FUNCTION UINT8_C(101)
+%define IMAGE_SYM_CLASS_END_OF_STRUCT UINT8_C(102)
+%define IMAGE_SYM_CLASS_FILE UINT8_C(103)
+%define IMAGE_SYM_CLASS_SECTION UINT8_C(104)
+%define IMAGE_SYM_CLASS_WEAK_EXTERNAL UINT8_C(105)
+%define IMAGE_SYM_CLASS_CLR_TOKEN UINT8_C(107)
+
+
+%define IMAGE_SYM_TYPE_NULL UINT16_C(0x0000)
+%define IMAGE_SYM_TYPE_VOID UINT16_C(0x0001)
+%define IMAGE_SYM_TYPE_CHAR UINT16_C(0x0002)
+%define IMAGE_SYM_TYPE_SHORT UINT16_C(0x0003)
+%define IMAGE_SYM_TYPE_INT UINT16_C(0x0004)
+%define IMAGE_SYM_TYPE_LONG UINT16_C(0x0005)
+%define IMAGE_SYM_TYPE_FLOAT UINT16_C(0x0006)
+%define IMAGE_SYM_TYPE_DOUBLE UINT16_C(0x0007)
+%define IMAGE_SYM_TYPE_STRUCT UINT16_C(0x0008)
+%define IMAGE_SYM_TYPE_UNION UINT16_C(0x0009)
+%define IMAGE_SYM_TYPE_ENUM UINT16_C(0x000a)
+%define IMAGE_SYM_TYPE_MOE UINT16_C(0x000b)
+%define IMAGE_SYM_TYPE_BYTE UINT16_C(0x000c)
+%define IMAGE_SYM_TYPE_WORD UINT16_C(0x000d)
+%define IMAGE_SYM_TYPE_UINT UINT16_C(0x000e)
+%define IMAGE_SYM_TYPE_DWORD UINT16_C(0x000f)
+%define IMAGE_SYM_TYPE_PCODE UINT16_C(0x8000)
+
+%define IMAGE_SYM_DTYPE_NULL UINT16_C(0x0)
+%define IMAGE_SYM_DTYPE_POINTER UINT16_C(0x1)
+%define IMAGE_SYM_DTYPE_FUNCTION UINT16_C(0x2)
+%define IMAGE_SYM_DTYPE_ARRAY UINT16_C(0x3)
+
+
+%define N_BTMASK UINT16_C(0x000f)
+%define N_TMASK UINT16_C(0x0030)
+%define N_TMASK1 UINT16_C(0x00c0)
+%define N_TMASK2 UINT16_C(0x00f0)
+%define N_BTSHFT 4
+%define N_TSHIFT 2
+
+
+;*******************************************************************************
+;* Structures and Typedefs *
+;*******************************************************************************
+
+struc IMAGE_FILE_HEADER
+ .Machine resw 1 ;;< 0x00
+ .NumberOfSections resw 1 ;;< 0x02
+ .TimeDateStamp resd 1 ;;< 0x04
+ .PointerToSymbolTable resd 1 ;;< 0x08
+ .NumberOfSymbols resd 1 ;;< 0x0c
+ .SizeOfOptionalHeader resw 1 ;;< 0x10
+ .Characteristics resw 1 ;;< 0x12
+endstruc
+AssertCompileSize(IMAGE_FILE_HEADER, 0x14)
+
+struc IMAGE_DATA_DIRECTORY
+ .VirtualAddress resd 1
+ .Size resd 1
+endstruc
+
+
+struc IMAGE_OPTIONAL_HEADER32
+ .Magic resw 1 ;;< 0x00
+ .MajorLinkerVersion resb 1 ;;< 0x02
+ .MinorLinkerVersion resb 1 ;;< 0x03
+ .SizeOfCode resd 1 ;;< 0x04
+ .SizeOfInitializedData resd 1 ;;< 0x08
+ .SizeOfUninitializedData resd 1 ;;< 0x0c
+ .AddressOfEntryPoint resd 1 ;;< 0x10
+ .BaseOfCode resd 1 ;;< 0x14
+ .BaseOfData resd 1 ;;< 0x18
+ .ImageBase resd 1 ;;< 0x1c
+ .SectionAlignment resd 1 ;;< 0x20
+ .FileAlignment resd 1 ;;< 0x24
+ .MajorOperatingSystemVersion resw 1 ;;< 0x28
+ .MinorOperatingSystemVersion resw 1 ;;< 0x2a
+ .MajorImageVersion resw 1 ;;< 0x2c
+ .MinorImageVersion resw 1 ;;< 0x2e
+ .MajorSubsystemVersion resw 1 ;;< 0x30
+ .MinorSubsystemVersion resw 1 ;;< 0x32
+ .Win32VersionValue resd 1 ;;< 0x34
+ .SizeOfImage resd 1 ;;< 0x38
+ .SizeOfHeaders resd 1 ;;< 0x3c
+ .CheckSum resd 1 ;;< 0x40
+ .Subsystem resw 1 ;;< 0x44
+ .DllCharacteristics resw 1 ;;< 0x46
+ .SizeOfStackReserve resd 1 ;;< 0x48
+ .SizeOfStackCommit resd 1 ;;< 0x4c
+ .SizeOfHeapReserve resd 1 ;;< 0x50
+ .SizeOfHeapCommit resd 1 ;;< 0x54
+ .LoaderFlags resd 1 ;;< 0x58
+ .NumberOfRvaAndSizes resd 1 ;;< 0x5c
+ .DataDirectory resb IMAGE_DATA_DIRECTORY_size * IMAGE_NUMBEROF_DIRECTORY_ENTRIES ;;< 0x60; 0x10*8 = 0x80
+endstruc
+AssertCompileSize(IMAGE_OPTIONAL_HEADER32, 0xe0);
+
+struc IMAGE_OPTIONAL_HEADER64
+ .Magic resw 1 ;;< 0x00
+ .MajorLinkerVersion resb 1 ;;< 0x02
+ .MinorLinkerVersion resb 1 ;;< 0x03
+ .SizeOfCode resd 1 ;;< 0x04
+ .SizeOfInitializedData resd 1 ;;< 0x08
+ .SizeOfUninitializedData resd 1 ;;< 0x0c
+ .AddressOfEntryPoint resd 1 ;;< 0x10
+ .BaseOfCode resd 1 ;;< 0x14
+ .ImageBase resq 1 ;;< 0x18
+ .SectionAlignment resd 1 ;;< 0x20
+ .FileAlignment resd 1 ;;< 0x24
+ .MajorOperatingSystemVersion resw 1 ;;< 0x28
+ .MinorOperatingSystemVersion resw 1 ;;< 0x2a
+ .MajorImageVersion resw 1 ;;< 0x2c
+ .MinorImageVersion resw 1 ;;< 0x2e
+ .MajorSubsystemVersion resw 1 ;;< 0x30
+ .MinorSubsystemVersion resw 1 ;;< 0x32
+ .Win32VersionValue resd 1 ;;< 0x34
+ .SizeOfImage resd 1 ;;< 0x38
+ .SizeOfHeaders resd 1 ;;< 0x3c
+ .CheckSum resd 1 ;;< 0x40
+ .Subsystem resw 1 ;;< 0x44
+ .DllCharacteristics resw 1 ;;< 0x46
+ .SizeOfStackReserve resq 1 ;;< 0x48
+ .SizeOfStackCommit resq 1 ;;< 0x50
+ .SizeOfHeapReserve resq 1 ;;< 0x58
+ .SizeOfHeapCommit resq 1 ;;< 0x60
+ .LoaderFlags resd 1 ;;< 0x68
+ .NumberOfRvaAndSizes resd 1 ;;< 0x6c
+ .DataDirectory resb IMAGE_DATA_DIRECTORY_size * IMAGE_NUMBEROF_DIRECTORY_ENTRIES ;;< 0x70; 0x10*8 = 0x80
+endstruc ; size: 0xf0
+AssertCompileSize(IMAGE_OPTIONAL_HEADER64, 0xf0);
+
+
+struc IMAGE_NT_HEADERS32
+ .Signature resd 1 ;;< 0x00
+ .FileHeader resb IMAGE_FILE_HEADER_size ; ;;< 0x04
+ .OptionalHeader resb IMAGE_OPTIONAL_HEADER32_size ;;< 0x18
+endstruc ; size: 0xf8
+AssertCompileSize(IMAGE_NT_HEADERS32, 0xf8);
+AssertCompileMemberOffset(IMAGE_NT_HEADERS32, FileHeader, 4);
+AssertCompileMemberOffset(IMAGE_NT_HEADERS32, OptionalHeader, 24);
+
+struc IMAGE_NT_HEADERS64
+ .Signature resd 1 ;;< 0x00
+ .FileHeader resb IMAGE_FILE_HEADER_size ;;< 0x04
+ .OptionalHeader resb IMAGE_OPTIONAL_HEADER64_size ;;< 0x18
+endstruc ; size: 0x108
+AssertCompileSize(IMAGE_NT_HEADERS64, 0x108);
+AssertCompileMemberOffset(IMAGE_NT_HEADERS64, FileHeader, 4);
+AssertCompileMemberOffset(IMAGE_NT_HEADERS64, OptionalHeader, 24);
+
+
+struc IMAGE_SECTION_HEADER
+ .Name resb IMAGE_SIZEOF_SHORT_NAME
+ .Misc.VirtualSize resd 1
+ .VirtualAddress resd 1
+ .SizeOfRawData resd 1
+ .PointerToRawData resd 1
+ .PointerToRelocations resd 1
+ .PointerToLinenumbers resd 1
+ .NumberOfRelocations resw 1
+ .NumberOfLinenumbers resw 1
+ .Characteristics resd 1
+endstruc
+%define IMAGE_SECTION_HEADER.Misc.PhysicalAddress IMAGE_SECTION_HEADER.Misc.VirtualSize
+
+
+struc IMAGE_BASE_RELOCATION
+ .VirtualAddress resd 1
+ .SizeOfBlock resd 1
+endstruc
+
+
+struc IMAGE_EXPORT_DIRECTORY
+ .Characteristics resd 1
+ .TimeDateStamp resd 1
+ .MajorVersion resw 1
+ .MinorVersion resw 1
+ .Name resd 1
+ .Base resd 1
+ .NumberOfFunctions resd 1
+ .NumberOfNames resd 1
+ .AddressOfFunctions resd 1
+ .AddressOfNames resd 1
+ .AddressOfNameOrdinals resd 1
+endstruc
+
+
+struc IMAGE_IMPORT_DESCRIPTOR
+ .u.Characteristics resd 1
+ .TimeDateStamp resd 1
+ .ForwarderChain resd 1
+ .Name resd 1
+ .FirstThunk resd 1
+endstruc
+%define IMAGE_IMPORT_DESCRIPTOR.u.OriginalFirstThunk IMAGE_IMPORT_DESCRIPTOR.u.Characteristics
+
+struc IMAGE_IMPORT_BY_NAME
+ .Hint resw 1
+ .Name resb 1
+endstruc
+
+
+struc IMAGE_THUNK_DATA64
+ .u1.ForwarderString resq 1
+endstruc
+%define IMAGE_THUNK_DATA64.u1.Function IMAGE_THUNK_DATA64.u1.ForwarderString
+%define IMAGE_THUNK_DATA64.u1.Ordinal IMAGE_THUNK_DATA64.u1.ForwarderString
+%define IMAGE_THUNK_DATA64.u1.AddressOfData IMAGE_THUNK_DATA64.u1.ForwarderString
+
+struc IMAGE_THUNK_DATA32
+ .u1.ForwarderString resd 1
+endstruc
+%define IMAGE_THUNK_DATA32.u1.Function IMAGE_THUNK_DATA32.u1.ForwarderString
+%define IMAGE_THUNK_DATA32.u1.Ordinal IMAGE_THUNK_DATA32.u1.ForwarderString
+%define IMAGE_THUNK_DATA32.u1.AddressOfData IMAGE_THUNK_DATA32.u1.ForwarderString
+
+
+struc IMAGE_LOAD_CONFIG_DIRECTORY32
+ .Size resd 1
+ .TimeDateStamp resd 1
+ .MajorVersion resw 1
+ .MinorVersion resw 1
+ .GlobalFlagsClear resd 1
+ .GlobalFlagsSet resd 1
+ .CriticalSectionDefaultTimeout resd 1
+ .DeCommitFreeBlockThreshold resd 1
+ .DeCommitTotalFreeThreshold resd 1
+ .LockPrefixTable resd 1
+ .MaximumAllocationSize resd 1
+ .VirtualMemoryThreshold resd 1
+ .ProcessHeapFlags resd 1
+ .ProcessAffinityMask resd 1
+ .CSDVersion resw 1
+ .Reserved1 resw 1
+ .EditList resd 1
+ .SecurityCookie resd 1
+ .SEHandlerTable resd 1
+ .SEHandlerCount resd 1
+endstruc
+
+struc IMAGE_LOAD_CONFIG_DIRECTORY64
+ .Size resd 1
+ .TimeDateStamp resd 1
+ .MajorVersion resw 1
+ .MinorVersion resw 1
+ .GlobalFlagsClear resd 1
+ .GlobalFlagsSet resd 1
+ .CriticalSectionDefaultTimeout resd 1
+ .DeCommitFreeBlockThreshold resq 1
+ .DeCommitTotalFreeThreshold resq 1
+ .LockPrefixTable resq 1
+ .MaximumAllocationSize resq 1
+ .VirtualMemoryThreshold resq 1
+ .ProcessAffinityMask resq 1
+ .ProcessHeapFlags resd 1
+ .CSDVersion resw 1
+ .Reserved1 resw 1
+ .EditList resq 1
+ .SecurityCookie resq 1
+ .SEHandlerTable resq 1
+ .SEHandlerCount resq 1
+endstruc
+
+
+struc IMAGE_DEBUG_DIRECTORY
+ .Characteristics resd 1
+ .TimeDateStamp resd 1
+ .MajorVersion resw 1
+ .MinorVersion resw 1
+ .Type resd 1
+ .SizeOfData resd 1
+ .AddressOfRawData resd 1
+ .PointerToRawData resd 1
+endstruc
+
+struc IMAGE_DEBUG_MISC
+ .DataType resd 1
+ .Length resd 1
+ .Unicode resb 1
+ .Reserved resb 3
+ .Data resb 1
+endstruc
+
+
+struc WIN_CERTIFICATE
+ .dwLength resd 1
+ .wRevision resw 1
+ .wCertificateType resw 1
+ .bCertificate resb 8
+endstruc
+
+;; The header of a .DBG file (NT4).
+struc IMAGE_SEPARATE_DEBUG_HEADER
+ .Signature resw 1 ;;< 0x00
+ .Flags resw 1 ;;< 0x02
+ .Machine resw 1 ;;< 0x04
+ .Characteristics resw 1 ;;< 0x06
+ .TimeDateStamp resd 1 ;;< 0x08
+ .CheckSum resd 1 ;;< 0x0c
+ .ImageBase resd 1 ;;< 0x10
+ .SizeOfImage resd 1 ;;< 0x14
+ .NumberOfSections resd 1 ;;< 0x18
+ .ExportedNamesSize resd 1 ;;< 0x1c
+ .DebugDirectorySize resd 1 ;;< 0x20
+ .SectionAlignment resd 1 ;;< 0x24
+ .Reserved resd 2 ;;< 0x28
+endstruc ; size: 0x30
+AssertCompileSize(IMAGE_SEPARATE_DEBUG_HEADER, 0x30);
+
+
+struc IMAGE_COFF_SYMBOLS_HEADER
+ .NumberOfSymbols resd 1
+ .LvaToFirstSymbol resd 1
+ .NumberOfLinenumbers resd 1
+ .LvaToFirstLinenumber resd 1
+ .RvaToFirstByteOfCode resd 1
+ .RvaToLastByteOfCode resd 1
+ .RvaToFirstByteOfData resd 1
+ .RvaToLastByteOfData resd 1
+endstruc
+AssertCompileSize(IMAGE_COFF_SYMBOLS_HEADER, 0x20);
+
+
+struc IMAGE_LINENUMBER
+ .Type.VirtualAddress resd 1
+ .Linenumber resw 1
+endstruc
+AssertCompileSize(IMAGE_LINENUMBER, 6);
+%define IMAGE_LINENUMBER.Type.SymbolTableIndex IMAGE_LINENUMBER.Type.VirtualAddress
+
+
+;;#pragma pack(2)
+;;struc IMAGE_SYMBOL
+;;{
+;; union
+;; {
+;; uint8_t ShortName[8];
+;; struct
+;; {
+;; .Short resd 1
+;; .Long resd 1
+;; } Name;
+;; uint32_t LongName[2];
+;; } N;
+;;
+;; .Value resd 1
+;; int16_t SectionNumber;
+;; .Type resw 1
+;; .StorageClass resb 1
+;; .NumberOfAuxSymbols resb 1
+;;} IMAGE_SYMBOL;
+;;#pragma pack()
+;;AssertCompileSize(IMAGE_SYMBOL, IMAGE_SIZE_OF_SYMBOL);
+;;
+;;
+;;#pragma pack(2)
+;;typedef struct IMAGE_AUX_SYMBOL_TOKEN_DEF
+;;{
+;; .bAuxType resb 1
+;; .bReserved resb 1
+;; .SymbolTableIndex resd 1
+;; uint8_t rgbReserved[12];
+;;} IMAGE_AUX_SYMBOL_TOKEN_DEF;
+;;#pragma pack()
+;;AssertCompileSize(IMAGE_AUX_SYMBOL_TOKEN_DEF, IMAGE_SIZE_OF_SYMBOL);
+;;
+;;
+;;#pragma pack(1)
+;;typedef union _IMAGE_AUX_SYMBOL
+;;{
+;; struct
+;; {
+;; .TagIndex resd 1
+;; union
+;; {
+;; struct
+;; {
+;; .Linenumber resw 1
+;; .Size resw 1
+;; } LnSz;
+;; } Misc;
+;; union
+;; {
+;; struct
+;; {
+;; .PointerToLinenumber resd 1
+;; .PointerToNextFunction resd 1
+;; } Function;
+;; struct
+;; {
+;; uint16_t Dimension[4];
+;; } Array;
+;; } FcnAry;
+;; .TvIndex resw 1
+;; } Sym;
+;;
+;; struct
+;; {
+;; uint8_t Name[IMAGE_SIZE_OF_SYMBOL];
+;; } File;
+;;
+;; struct
+;; {
+;; .Length resd 1
+;; .NumberOfRelocations resw 1
+;; .NumberOfLinenumbers resw 1
+;; .CheckSum resd 1
+;; .Number resw 1
+;; .Selection resb 1
+;; .bReserved resb 1
+;; .HighNumber resw 1
+;; } Section;
+;;
+;; IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;
+;; struct
+;; {
+;; .crc resd 1
+;; uint8_t rgbReserved[14];
+;; } CRC;
+;;} IMAGE_AUX_SYMBOL;
+;;#pragma pack()
+;;AssertCompileSize(IMAGE_AUX_SYMBOL, IMAGE_SIZE_OF_SYMBOL);
+;;
+;;
+;;
+;;struc IMAGE_SYMBOL_EX
+;;{
+;; union
+;; {
+;; uint8_t ShortName[8];
+;; struct
+;; {
+;; .Short resd 1
+;; .Long resd 1
+;; } Name;
+;; uint32_t LongName[2];
+;; } N;
+;;
+;; .Value resd 1
+;; int32_t SectionNumber; /* The difference from IMAGE_SYMBOL
+;; .Type resw 1
+;; .StorageClass resb 1
+;; .NumberOfAuxSymbols resb 1
+;;} IMAGE_SYMBOL_EX;
+;;AssertCompileSize(IMAGE_SYMBOL_EX, IMAGE_SIZE_OF_SYMBOL_EX);
+;;
+;;
+;;typedef union _IMAGE_AUX_SYMBOL_EX
+;;{
+;; struct
+;; {
+;; .WeakDefaultSymIndex resd 1
+;; .WeakSearchType resd 1
+;; uint8_t rgbReserved[12];
+;; } Sym;
+;;
+;; struct
+;; {
+;; uint8_t Name[IMAGE_SIZE_OF_SYMBOL_EX];
+;; } File;
+;;
+;; struct
+;; {
+;; .Length resd 1
+;; .NumberOfRelocations resw 1
+;; .NumberOfLinenumbers resw 1
+;; .CheckSum resd 1
+;; .Number resw 1
+;; .Selection resb 1
+;; .bReserved resb 1
+;; .HighNumber resw 1
+;; uint8_t rgbReserved[2];
+;; } Section;
+;;
+;; IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;
+;;
+;; struct
+;; {
+;; .crc resd 1
+;; uint8_t rgbReserved[16];
+;; } CRC;
+;;} IMAGE_AUX_SYMBOL_EX;
+;;AssertCompileSize(IMAGE_AUX_SYMBOL_EX, IMAGE_SIZE_OF_SYMBOL_EX);
+
+%endif
+
diff --git a/include/iprt/formats/xar.h b/include/iprt/formats/xar.h
new file mode 100644
index 00000000..5cb1eaa1
--- /dev/null
+++ b/include/iprt/formats/xar.h
@@ -0,0 +1,68 @@
+/** @file
+ * IPRT - Extensible Archiver (XAR) format.
+ */
+
+/*
+ * Copyright (C) 2013 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.
+ */
+
+
+#ifndef ___iprt_formats_xar_h
+#define ___iprt_formats_xar_h
+
+
+#pragma pack(4) /* Misdesigned header, not 8-byte aligned size. */
+typedef struct XARHEADER
+{
+ /** The magic number 'xar!' (XAR_HEADER_MAGIC). */
+ uint32_t u32Magic;
+ /** The size of this header structure. */
+ uint16_t cbHeader;
+ /** The header version structure. */
+ uint16_t uVersion;
+ /** The size of the compressed table of content (TOC). */
+ uint64_t cbTocCompressed;
+ /** The size of the table of context (TOC) when not compressed. */
+ uint64_t cbTocUncompressed;
+ /** Which cryptographic hash function is used (XAR_HASH_XXX). */
+ uint32_t uHashFunction;
+} XARHEADER;
+#pragma pack()
+/** Pointer to a XAR header. */
+typedef XARHEADER *PXARHEADER;
+/** Pointer to a const XAR header. */
+typedef XARHEADER const *PCXARHEADER;
+
+/** XAR magic value (on disk endian). */
+#define XAR_HEADER_MAGIC RT_H2LE_U32(RT_MAKE_U32_FROM_U8('x', 'a', 'r', '!'))
+/** The current header version value (host endian). */
+#define XAR_HEADER_VERSION 1
+
+/** @name XAR hashing functions.
+ * @{ */
+#define XAR_HASH_NONE 0
+#define XAR_HASH_SHA1 1
+#define XAR_HASH_MD5 2
+#define XAR_HASH_MAX 2
+/** @} */
+
+
+#endif
+
diff --git a/include/iprt/fs.h b/include/iprt/fs.h
index 6ad2d2c5..3055bf4b 100644
--- a/include/iprt/fs.h
+++ b/include/iprt/fs.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -93,6 +93,11 @@ RT_C_DECLS_BEGIN
/** Other executable (S_IXOTH). */
#define RTFS_UNIX_IXOTH 0000001U
+/** All UNIX access permission bits (0777). */
+#define RTFS_UNIX_ALL_ACCESS_PERMS 0000777U
+/** All UNIX permission bits, including set id and sticky bits. */
+#define RTFS_UNIX_ALL_PERMS 0007777U
+
/** Named pipe (fifo) (S_IFIFO). */
#define RTFS_TYPE_FIFO 0010000U
/** Character device (S_IFCHR). */
@@ -216,6 +221,7 @@ typedef enum RTFSTYPE
RTFSTYPE_SYSFS,
RTFSTYPE_PROC,
RTFSTYPE_OCFS2,
+ RTFSTYPE_BTRFS,
/* Windows: */
/** New Technology File System. */
diff --git a/include/iprt/getopt.h b/include/iprt/getopt.h
index bf976cef..042a6e5c 100644
--- a/include/iprt/getopt.h
+++ b/include/iprt/getopt.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2007-2011 Oracle Corporation
+ * Copyright (C) 2007-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -69,12 +69,20 @@ RT_C_DECLS_BEGIN
/** The value must be a valid IPv4 address.
* (Not a name, but 4 values in the 0..255 range with dots separating them). */
#define RTGETOPT_REQ_IPV4ADDR 10
-#if 0
/** The value must be a valid IPv4 CIDR.
* As with RTGETOPT_REQ_IPV4ADDR, no name.
- * @todo Mix CIDR with types.h or/and net.h first and find a way to make the
- * mask optional like with ifconfig. See RTCidrStrToIPv4. */
+ */
#define RTGETOPT_REQ_IPV4CIDR 11
+#if 0
+/* take placers */
+/** The value must be a valid IPv6 addr
+ * @todo: Add types and parsing routines in (iprt/net.h)
+ */
+#define RTGETOPT_REQ_IPV6ADDR 12
+/** The value must be a valid IPv6 CIDR
+ * @todo: Add types and parsing routines in (iprt/net.h)
+ */
+#define RTGETOPT_REQ_IPV6CIDR 13
#endif
/** The value must be a valid ethernet MAC address. */
#define RTGETOPT_REQ_MACADDR 14
@@ -163,6 +171,12 @@ typedef union RTGETOPTUNION
#ifdef ___iprt_net_h
/** A RTGETOPT_REQ_IPV4ADDR option argument. */
RTNETADDRIPV4 IPv4Addr;
+ /** A RTGETOPT_REQ_IPV4CIDR option argument. */
+ struct
+ {
+ RTNETADDRIPV4 IPv4Network;
+ RTNETADDRIPV4 IPv4Netmask;
+ } CidrIPv4;
#endif
/** A RTGETOPT_REQ_MACADDR option argument. */
RTMAC MacAddr;
@@ -379,7 +393,7 @@ RTDECL(RTEXITCODE) RTGetOptPrintError(int ch, PCRTGETOPTUNION pValueUnion);
* This is useful for converting a response file or similar to an argument
* vector that can be used with RTGetOptInit().
*
- * This function aims at following the bourn shell string quoting rules.
+ * This function aims at following the bourne shell string quoting rules.
*
* @returns IPRT status code.
*
diff --git a/include/iprt/handletable.h b/include/iprt/handletable.h
index 0ade7412..c26f7871 100644
--- a/include/iprt/handletable.h
+++ b/include/iprt/handletable.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -89,12 +89,15 @@ typedef FNRTHANDLETABLEDELETE *PFNRTHANDLETABLEDELETE;
*
* Setting this means you will have to use the WithCtx functions to do the
* handle management. */
-#define RTHANDLETABLE_FLAGS_CONTEXT RT_BIT_32(0)
-/** Whether the handle table should take care of the serialization.
+#define RTHANDLETABLE_FLAGS_CONTEXT RT_BIT_32(0)
+/** Whether the handle table should take care of the serialization (IRQ unsafe).
* If not specified the caller will have to take care of that. */
-#define RTHANDLETABLE_FLAGS_LOCKED RT_BIT_32(1)
+#define RTHANDLETABLE_FLAGS_LOCKED RT_BIT_32(1)
+/** Like RTHANDLETABLE_FLAGS_LOCKED, except it's IRQ safe.
+ * A side-effect is that callbacks may be called with IRQs disabled. */
+#define RTHANDLETABLE_FLAGS_LOCKED_IRQ_SAFE RT_BIT_32(2)
/** The mask of valid flags. */
-#define RTHANDLETABLE_FLAGS_MASK UINT32_C(0x00000003)
+#define RTHANDLETABLE_FLAGS_MASK UINT32_C(0x00000007)
/** @} */
diff --git a/include/iprt/heap.h b/include/iprt/heap.h
index f9e0c524..4151fac0 100644
--- a/include/iprt/heap.h
+++ b/include/iprt/heap.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2009 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/http.h b/include/iprt/http.h
new file mode 100644
index 00000000..dc4a8cc5
--- /dev/null
+++ b/include/iprt/http.h
@@ -0,0 +1,169 @@
+/* $Id: http.h $ */
+/** @file
+ * IPRT - Simple HTTP Communication API.
+ */
+
+/*
+ * Copyright (C) 2012-2013 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.
+ */
+
+#ifndef ___iprt_http_h
+#define ___iprt_http_h
+
+#include <iprt/types.h>
+
+RT_C_DECLS_BEGIN
+
+/** @defgroup grp_rt_http RTHttp - Simple HTTP API
+ * @ingroup grp_rt
+ * @{
+ */
+
+/** @todo the following three definitions may move the iprt/types.h later. */
+/** RTHTTP interface handle. */
+typedef R3PTRTYPE(struct RTHTTPINTERNAL *) RTHTTP;
+/** Pointer to a RTHTTP interface handle. */
+typedef RTHTTP *PRTHTTP;
+/** Nil RTHTTP interface handle. */
+#define NIL_RTHTTP ((RTHTTP)0)
+
+
+/**
+ * Creates a HTTP interface handle.
+ *
+ * @returns iprt status code.
+ *
+ * @param phHttp Where to store the HTTP handle.
+ */
+RTR3DECL(int) RTHttpCreate(PRTHTTP phHttp);
+
+/**
+ * Destroys a HTTP interface handle.
+ *
+ * @param hHttp Handle to the HTTP interface.
+ */
+RTR3DECL(void) RTHttpDestroy(RTHTTP hHttp);
+
+/**
+ * Perform a simple blocking HTTP request.
+ *
+ * @returns iprt status code.
+ *
+ * @param hHttp HTTP interface handle.
+ * @param pcszUrl URL.
+ * @param ppszResponse HTTP response. It is guaranteed that this string is
+ * '\0'-terminated.
+ */
+RTR3DECL(int) RTHttpGet(RTHTTP hHttp, const char *pcszUrl, char **ppszResponse);
+
+/**
+ * Perform a simple blocking HTTP request, writing the output to a file.
+ *
+ * @returns iprt status code.
+ *
+ * @param hHttp HTTP interface handle.
+ * @param pszUrl URL.
+ * @param pszDstFile The destination file name.
+ */
+RTR3DECL(int) RTHttpGetFile(RTHTTP hHttp, const char *pszUrl, const char *pszDstFile);
+
+/**
+ * Abort a pending HTTP request. A blocking RTHttpGet() call will return with
+ * VERR_HTTP_ABORTED. It may take some time (current cURL implementation needs
+ * up to 1 second) before the request is aborted.
+ *
+ * @returns iprt status code.
+ *
+ * @param hHttp HTTP interface handle.
+ */
+RTR3DECL(int) RTHttpAbort(RTHTTP hHttp);
+
+/**
+ * Tells the HTTP interface to use the system proxy configuration.
+ *
+ * @returns iprt status code.
+ * @param hHttp HTTP interface handle.
+ */
+RTR3DECL(int) RTHttpUseSystemProxySettings(RTHTTP hHttp);
+
+/**
+ * Specify proxy settings.
+ *
+ * @returns iprt status code.
+ *
+ * @param hHttp HTTP interface handle.
+ * @param pcszProxy URL of the proxy
+ * @param uPort port number of the proxy, use 0 for not specifying a port.
+ * @param pcszUser username, pass NULL for no authentication
+ * @param pcszPwd password, pass NULL for no authentication
+ */
+RTR3DECL(int) RTHttpSetProxy(RTHTTP hHttp, const char *pcszProxyUrl, uint32_t uPort,
+ const char *pcszProxyUser, const char *pcszProxyPwd);
+
+/**
+ * Set custom headers.
+ *
+ * @returns iprt status code.
+ *
+ * @param hHttp HTTP interface handle.
+ * @param cHeaders number of custom headers.
+ * @param pcszHeaders array of headers in form "foo: bar".
+ */
+RTR3DECL(int) RTHttpSetHeaders(RTHTTP hHttp, size_t cHeaders, const char * const *papszHeaders);
+
+/**
+ * Set a custom certification authority file, containing root certificates.
+ *
+ * @returns iprt status code.
+ *
+ * @param hHttp HTTP interface handle.
+ * @param pcszCAFile File name containing root certificates.
+ */
+RTR3DECL(int) RTHttpSetCAFile(RTHTTP hHttp, const char *pcszCAFile);
+
+
+/**
+ * Determine the digest (fingerprint) of a certificate. Allocate memory for
+ * storing the SHA1 fingerprint as well as the SHA512 fingerprint. This
+ * memory has to be freed by RTMemFree().
+ *
+ * @todo Move this function to somewhere else.
+ *
+ * @returns iprt status code.
+ *
+ * @param hHttp HTTP interface handle (ignored).
+ * @param pcszCert The certificate in PEM format.
+ * @param cbCert Size of the certificate.
+ * @param pabSha1 Where to store the pointer to the SHA1 fingerprint.
+ * @param pcbSha1 Where to store the size of the SHA1 fingerprint.
+ * @param pabSha512 Where to store the pointer to the SHA512 fingerprint.
+ * @param pcbSha512 Where to store the size of the SHA512 fingerprint.
+ */
+RTR3DECL(int) RTHttpCertDigest(RTHTTP hHttp, char *pcszCert, size_t cbCert,
+ uint8_t **pabSha1, size_t *pcbSha1,
+ uint8_t **pabSha512, size_t *pcbSha512);
+
+
+/** @} */
+
+RT_C_DECLS_END
+
+#endif
+
diff --git a/include/iprt/initterm.h b/include/iprt/initterm.h
index 9fff94fc..1853fbb3 100644
--- a/include/iprt/initterm.h
+++ b/include/iprt/initterm.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2009 Oracle Corporation
+ * Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -46,6 +46,10 @@ RT_C_DECLS_BEGIN
#define RTR3INIT_FLAGS_SUPLIB RT_BIT(0)
/** Initializing IPRT from a DLL. */
#define RTR3INIT_FLAGS_DLL RT_BIT(1)
+/** We are sharing a process space, so we need to behave. */
+#define RTR3INIT_FLAGS_UNOBTRUSIVE RT_BIT(2)
+/** The caller ensures that the argument bector is UTF-8. */
+#define RTR3INIT_FLAGS_UTF8_ARGV RT_BIT(3)
/** @} */
/** @name RTR3InitEx version
@@ -103,6 +107,11 @@ RTR3DECL(int) RTR3InitEx(uint32_t iVersion, uint32_t fFlags, int cArgs, char ***
*/
RTR3DECL(void) RTR3Term(void);
+/**
+ * Are we running in unobtrusive mode?
+ * @returns true/false.
+ */
+RTR3DECL(bool) RTR3InitIsUnobtrusive(void);
#endif /* IN_RING3 */
diff --git a/include/iprt/isofs.h b/include/iprt/isofs.h
index c7774cd9..e6f3356e 100644
--- a/include/iprt/isofs.h
+++ b/include/iprt/isofs.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/include/iprt/ldr.h b/include/iprt/ldr.h
index 9e036d83..80c432de 100644
--- a/include/iprt/ldr.h
+++ b/include/iprt/ldr.h
@@ -3,7 +3,7 @@
*/
/*
- * 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;
@@ -51,6 +51,87 @@ typedef RTLDRADDR const *PCRTLDRADDR;
/**
+ * Loader module format.
+ */
+typedef enum RTLDRFMT
+{
+ /** The usual invalid 0 format. */
+ RTLDRFMT_INVALID = 0,
+ /** The native OS loader. */
+ RTLDRFMT_NATIVE,
+ /** The AOUT loader. */
+ RTLDRFMT_AOUT,
+ /** The ELF loader. */
+ RTLDRFMT_ELF,
+ /** The LX loader. */
+ RTLDRFMT_LX,
+ /** The Mach-O loader. */
+ RTLDRFMT_MACHO,
+ /** The PE loader. */
+ RTLDRFMT_PE,
+ /** The end of the valid format values (exclusive). */
+ RTLDRFMT_END,
+ /** Hack to blow the type up to 32-bit. */
+ RTLDRFMT_32BIT_HACK = 0x7fffffff
+} RTLDRFMT;
+
+
+/**
+ * Loader module type.
+ */
+typedef enum RTLDRTYPE
+{
+ /** The usual invalid 0 type. */
+ RTLDRTYPE_INVALID = 0,
+ /** Object file. */
+ RTLDRTYPE_OBJECT,
+ /** Executable module, fixed load address. */
+ RTLDRTYPE_EXECUTABLE_FIXED,
+ /** Executable module, relocatable, non-fixed load address. */
+ RTLDRTYPE_EXECUTABLE_RELOCATABLE,
+ /** Executable module, position independent code, non-fixed load address. */
+ RTLDRTYPE_EXECUTABLE_PIC,
+ /** Shared library, fixed load address.
+ * Typically a system library. */
+ RTLDRTYPE_SHARED_LIBRARY_FIXED,
+ /** Shared library, relocatable, non-fixed load address. */
+ RTLDRTYPE_SHARED_LIBRARY_RELOCATABLE,
+ /** Shared library, position independent code, non-fixed load address. */
+ RTLDRTYPE_SHARED_LIBRARY_PIC,
+ /** DLL that contains no code or data only imports and exports. (Chiefly OS/2.) */
+ RTLDRTYPE_FORWARDER_DLL,
+ /** Core or dump. */
+ RTLDRTYPE_CORE,
+ /** Debug module (debug info with empty code & data segments). */
+ RTLDRTYPE_DEBUG_INFO,
+ /** The end of the valid types values (exclusive). */
+ RTLDRTYPE_END,
+ /** Hack to blow the type up to 32-bit. */
+ RTLDRTYPE_32BIT_HACK = 0x7fffffff
+} RTLDRTYPE;
+
+
+/**
+ * Loader endian indicator.
+ */
+typedef enum RTLDRENDIAN
+{
+ /** The usual invalid endian. */
+ RTLDRENDIAN_INVALID,
+ /** Little endian. */
+ RTLDRENDIAN_LITTLE,
+ /** Bit endian. */
+ RTLDRENDIAN_BIG,
+ /** Endianness doesn't have a meaning in the context. */
+ RTLDRENDIAN_NA,
+ /** The end of the valid endian values (exclusive). */
+ RTLDRENDIAN_END,
+ /** Hack to blow the type up to 32-bit. */
+ RTLDRENDIAN_32BIT_HACK = 0x7fffffff
+} RTLDRENDIAN;
+
+
+/**
* Gets the default file suffix for DLL/SO/DYLIB/whatever.
*
* @returns The stuff (readonly).
@@ -113,11 +194,36 @@ RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fF
/** Symbols defined in this library will be made available for symbol
* resolution of subsequently loaded libraries. */
#define RTLDRLOAD_FLAGS_GLOBAL RT_BIT_32(0)
+/** Do not unload the library upon RTLdrClose. (For system libs.) */
+#define RTLDRLOAD_FLAGS_NO_UNLOAD RT_BIT_32(1)
/** The mask of valid flag bits. */
-#define RTLDRLOAD_FLAGS_VALID_MASK UINT32_C(0x00000001)
+#define RTLDRLOAD_FLAGS_VALID_MASK UINT32_C(0x00000003)
/** @} */
/**
+ * Loads a dynamic load library (/shared object) image file residing in one of
+ * the default system library locations.
+ *
+ * Only the system library locations are searched. No suffix is required.
+ *
+ * @returns iprt status code.
+ * @param pszFilename Image filename. No path.
+ * @param fNoUnload Do not unload the library when RTLdrClose is called.
+ * @param phLdrMod Where to store the handle to the loaded module.
+ */
+RTDECL(int) RTLdrLoadSystem(const char *pszFilename, bool fNoUnload, PRTLDRMOD phLdrMod);
+
+/**
+ * Combines RTLdrLoadSystem and RTLdrGetSymbol, with fNoUnload set to true.
+ *
+ * @returns The symbol value, NULL on failure. (If you care for a less boolean
+ * status, go thru the necessary API calls yourself.)
+ * @param pszFilename Image filename. No path.
+ * @param pszSymbol Symbol name.
+ */
+RTDECL(void *) RTLdrGetSystemSymbol(const char *pszFilename, const char *pszSymbol);
+
+/**
* Loads a dynamic load library (/shared object) image file residing in the
* RTPathAppPrivateArch() directory.
*
@@ -130,6 +236,16 @@ RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fF
RTDECL(int) RTLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod);
/**
+ * Gets the native module handle for a module loaded by RTLdrLoad, RTLdrLoadEx,
+ * RTLdrLoadSystem, or RTLdrLoadAppPriv.
+ *
+ * @returns Native handle on success, ~(uintptr_t)0 on failure.
+ * @param hLdrMod The loader module handle.
+ */
+RTDECL(uintptr_t) RTLdrGetNativeHandle(RTLDRMOD hLdrMod);
+
+
+/**
* Image architecuture specifier for RTLdrOpenEx.
*/
typedef enum RTLDRARCH
@@ -151,12 +267,21 @@ typedef enum RTLDRARCH
/** Pointer to a RTLDRARCH. */
typedef RTLDRARCH *PRTLDRARCH;
+/** @name RTLDR_O_XXX - RTLdrOpen flags.
+ * @{ */
+/** Open for debugging or introspection reasons.
+ * This will skip a few of the stricter validations when loading images. */
+#define RTLDR_O_FOR_DEBUG RT_BIT_32(0)
+/** Mask of valid flags. */
+#define RTLDR_O_VALID_MASK UINT32_C(0x00000001)
+/** @} */
+
/**
* Open a binary image file, extended version.
*
* @returns iprt status code.
* @param pszFilename Image filename.
- * @param fFlags Reserved, MBZ.
+ * @param fFlags Valid RTLDR_O_XXX combination.
* @param enmArch CPU architecture specifier for the image to be loaded.
* @param phLdrMod Where to store the handle to the loader module.
*/
@@ -166,53 +291,72 @@ RTDECL(int) RTLdrOpen(const char *pszFilename, uint32_t fFlags, RTLDRARCH enmArc
* Opens a binary image file using kLdr.
*
* @returns iprt status code.
- * @param pszFilename Image filename.
- * @param phLdrMod Where to store the handle to the loaded module.
- * @param fFlags Reserved, MBZ.
+ * @param pszFilename Image filename.
+ * @param phLdrMod Where to store the handle to the loaded module.
+ * @param fFlags Valid RTLDR_O_XXX combination.
* @param enmArch CPU architecture specifier for the image to be loaded.
* @remark Primarily for testing the loader.
*/
RTDECL(int) RTLdrOpenkLdr(const char *pszFilename, uint32_t fFlags, RTLDRARCH enmArch, PRTLDRMOD phLdrMod);
+
/**
- * What to expect and do with the bits passed to RTLdrOpenBits().
+ * Called to read @a cb bytes at @a off into @a pvBuf.
+ *
+ * @returns IPRT status code
+ * @param pvBuf The output buffer.
+ * @param cb The number of bytes to read.
+ * @param off Where to start reading.
+ * @param pvUser The user parameter.
*/
-typedef enum RTLDROPENBITS
-{
- /** The usual invalid 0 entry. */
- RTLDROPENBITS_INVALID = 0,
- /** The bits are readonly and will never be changed. */
- RTLDROPENBITS_READONLY,
- /** The bits are going to be changed and the loader will have to duplicate them
- * when opening the image. */
- RTLDROPENBITS_WRITABLE,
- /** The bits are both the source and destination for the loader operation.
- * This means that the loader may have to duplicate them prior to changing them. */
- RTLDROPENBITS_SRC_AND_DST,
- /** The end of the valid enums. This entry marks the
- * first invalid entry.. */
- RTLDROPENBITS_END,
- RTLDROPENBITS_32BIT_HACK = 0x7fffffff
-} RTLDROPENBITS;
-
-/**
- * Open a binary image from in-memory bits.
+typedef DECLCALLBACK(int) FNRTLDRRDRMEMREAD(void *pvBuf, size_t cb, size_t off, void *pvUser);
+/** Pointer to a RTLdrOpenInMemory reader callback. */
+typedef FNRTLDRRDRMEMREAD *PFNRTLDRRDRMEMREAD;
+
+/**
+ * Called to when the module is unloaded (or done loading) to release resources
+ * associated with it (@a pvUser).
*
- * @returns iprt status code.
- * @param pvBits The start of the raw-image.
- * @param cbBits The size of the raw-image.
- * @param enmBits What to expect from the pvBits.
- * @param pszLogName What to call the raw-image when logging.
- * For RTLdrLoad and RTLdrOpen the filename is used for this.
- * @param phLdrMod Where to store the handle to the loader module.
+ * @returns IPRT status code
+ * @param pvUser The user parameter.
*/
-RTDECL(int) RTLdrOpenBits(const void *pvBits, size_t cbBits, RTLDROPENBITS enmBits, const char *pszLogName, PRTLDRMOD phLdrMod);
+typedef DECLCALLBACK(void) FNRTLDRRDRMEMDTOR(void *pvUser);
+/** Pointer to a RTLdrOpenInMemory destructor callback. */
+typedef FNRTLDRRDRMEMDTOR *PFNRTLDRRDRMEMDTOR;
+
+/**
+ * Open a in-memory image or an image with a custom reader callback.
+ *
+ * @returns IPRT status code.
+ * @param pszName The image name.
+ * @param fFlags Valid RTLDR_O_XXX combination.
+ * @param enmArch CPU architecture specifier for the image to be loaded.
+ * @param cbImage The size of the image (fake file).
+ * @param pfnRead The read function. If NULL is passed in, a default
+ * reader function is provided that assumes @a pvUser
+ * points to the raw image bits, at least @a cbImage of
+ * valid memory.
+ * @param pfnDtor The destructor function. If NULL is passed, a default
+ * destructor will be provided that passes @a pvUser to
+ * RTMemFree.
+ * @param pvUser The user argument or, if any of the callbacks are NULL,
+ * a pointer to a memory block.
+ * @param phLdrMod Where to return the module handle.
+ *
+ * @remarks With the exception of invalid @a pfnDtor and/or @a pvUser
+ * parameters, the pfnDtor methods (or the default one if NULL) will
+ * always be invoked. The destruction of pvUser is entirely in the
+ * hands of this method once it's called.
+ */
+RTDECL(int) RTLdrOpenInMemory(const char *pszName, uint32_t fFlags, RTLDRARCH enmArch, size_t cbImage,
+ PFNRTLDRRDRMEMREAD pfnRead, PFNRTLDRRDRMEMDTOR pfnDtor, void *pvUser,
+ PRTLDRMOD phLdrMod);
/**
* Closes a loader module handle.
*
* The handle can be obtained using any of the RTLdrLoad(), RTLdrOpen()
- * and RTLdrOpenBits() functions.
+ * and RTLdrOpenInMemory() functions.
*
* @returns iprt status code.
* @param hLdrMod The loader module handle.
@@ -250,14 +394,28 @@ RTDECL(int) RTLdrGetSymbol(RTLDRMOD hLdrMod, const char *pszSymbol, void **ppvVa
RTDECL(int) RTLdrGetSymbolEx(RTLDRMOD hLdrMod, const void *pvBits, RTLDRADDR BaseAddress, const char *pszSymbol,
PRTLDRADDR pValue);
+
+/**
+ * Gets the address of a named exported function.
+ *
+ * Same as RTLdrGetSymbol, but skips the status code and pointer to return
+ * variable stuff.
+ *
+ * @returns Pointer to the function if found, NULL if not.
+ * @param hLdrMod The loader module handle.
+ * @param pszSymbol Function name.
+ */
+RTDECL(PFNRT) RTLdrGetFunction(RTLDRMOD hLdrMod, const char *pszSymbol);
+
/**
* Gets the size of the loaded image.
- * This is only supported for modules which has been opened using RTLdrOpen() and RTLdrOpenBits().
+ *
+ * This is not necessarily available for images that has been loaded using
+ * RTLdrLoad().
*
* @returns image size (in bytes).
- * @returns ~(size_t)0 on if not opened by RTLdrOpen().
+ * @returns ~(size_t)0 on if not available.
* @param hLdrMod Handle to the loader module.
- * @remark Not supported for RTLdrLoad() images.
*/
RTDECL(size_t) RTLdrSize(RTLDRMOD hLdrMod);
@@ -341,7 +499,9 @@ RTDECL(int) RTLdrEnumSymbols(RTLDRMOD hLdrMod, unsigned fFlags, const void *pvBi
/** @name RTLdrEnumSymbols flags.
* @{ */
/** Returns ALL kinds of symbols. The default is to only return public/exported symbols. */
-#define RTLDR_ENUM_SYMBOL_FLAGS_ALL RT_BIT(1)
+#define RTLDR_ENUM_SYMBOL_FLAGS_ALL RT_BIT(1)
+/** Ignore forwarders (for use with RTLDR_ENUM_SYMBOL_FLAGS_ALL). */
+#define RTLDR_ENUM_SYMBOL_FLAGS_NO_FWD RT_BIT(2)
/** @} */
@@ -358,8 +518,18 @@ typedef enum RTLDRDBGINFOTYPE
RTLDRDBGINFOTYPE_STABS,
/** Debug With Arbitrary Record Format (DWARF). */
RTLDRDBGINFOTYPE_DWARF,
+ /** Debug With Arbitrary Record Format (DWARF), in external file (DWO). */
+ RTLDRDBGINFOTYPE_DWARF_DWO,
/** Microsoft Codeview debug info. */
RTLDRDBGINFOTYPE_CODEVIEW,
+ /** Microsoft Codeview debug info, in external v2.0+ program database (PDB). */
+ RTLDRDBGINFOTYPE_CODEVIEW_PDB20,
+ /** Microsoft Codeview debug info, in external v7.0+ program database (PDB). */
+ RTLDRDBGINFOTYPE_CODEVIEW_PDB70,
+ /** Microsoft Codeview debug info, in external file (DBG). */
+ RTLDRDBGINFOTYPE_CODEVIEW_DBG,
+ /** Microsoft COFF debug info. */
+ RTLDRDBGINFOTYPE_COFF,
/** Watcom debug info. */
RTLDRDBGINFOTYPE_WATCOM,
/** IBM High Level Language debug info.. */
@@ -370,6 +540,96 @@ typedef enum RTLDRDBGINFOTYPE
RTLDRDBGINFOTYPE_32BIT_HACK = 0x7fffffff
} RTLDRDBGINFOTYPE;
+
+/**
+ * Debug info details for the enumeration callback.
+ */
+typedef struct RTLDRDBGINFO
+{
+ /** The kind of debug info. */
+ RTLDRDBGINFOTYPE enmType;
+ /** The debug info ordinal number / id. */
+ uint32_t iDbgInfo;
+ /** The file offset *if* this type has one specific location in the executable
+ * image file. This is -1 if there isn't any specific file location. */
+ RTFOFF offFile;
+ /** The link address of the debug info if it's loadable. NIL_RTLDRADDR if not
+ * loadable*/
+ RTLDRADDR LinkAddress;
+ /** The size of the debug information. -1 is used if this isn't applicable.*/
+ RTLDRADDR cb;
+ /** This is set if the debug information is found in an external file. NULL
+ * if no external file involved.
+ * @note Putting it outside the union to allow lazy callback implementation. */
+ const char *pszExtFile;
+ /** Type (enmType) specific information. */
+ union
+ {
+ /** RTLDRDBGINFOTYPE_DWARF */
+ struct
+ {
+ /** The section name. */
+ const char *pszSection;
+ } Dwarf;
+
+ /** RTLDRDBGINFOTYPE_DWARF_DWO */
+ struct
+ {
+ /** The CRC32 of the external file. */
+ uint32_t uCrc32;
+ } Dwo;
+
+ /** RTLDRDBGINFOTYPE_CODEVIEW, RTLDRDBGINFOTYPE_COFF */
+ struct
+ {
+ /** The PE image size. */
+ uint32_t cbImage;
+ /** The timestamp. */
+ uint32_t uTimestamp;
+ /** The major version from the entry. */
+ uint32_t uMajorVer;
+ /** The minor version from the entry. */
+ uint32_t uMinorVer;
+ } Cv, Coff;
+
+ /** RTLDRDBGINFOTYPE_CODEVIEW_DBG */
+ struct
+ {
+ /** The PE image size. */
+ uint32_t cbImage;
+ /** The timestamp. */
+ uint32_t uTimestamp;
+ } Dbg;
+
+ /** RTLDRDBGINFOTYPE_CODEVIEW_PDB20*/
+ struct
+ {
+ /** The PE image size. */
+ uint32_t cbImage;
+ /** The timestamp. */
+ uint32_t uTimestamp;
+ /** The PDB age. */
+ uint32_t uAge;
+ } Pdb20;
+
+ /** RTLDRDBGINFOTYPE_CODEVIEW_PDB70 */
+ struct
+ {
+ /** The PE image size. */
+ uint32_t cbImage;
+ /** The PDB age. */
+ uint32_t uAge;
+ /** The UUID. */
+ RTUUID Uuid;
+ } Pdb70;
+ } u;
+} RTLDRDBGINFO;
+/** Pointer to debug info details. */
+typedef RTLDRDBGINFO *PRTLDRDBGINFO;
+/** Pointer to read only debug info details. */
+typedef RTLDRDBGINFO const *PCRTLDRDBGINFO;
+
+
/**
* Debug info enumerator callback.
*
@@ -377,30 +637,10 @@ typedef enum RTLDRDBGINFOTYPE
* will cause RTLdrEnumDbgInfo to immediately return with that status.
*
* @param hLdrMod The module handle.
- * @param iDbgInfo The debug info ordinal number / id.
- * @param enmType The debug info type.
- * @param iMajorVer The major version number of the debug info format.
- * -1 if unknow - implies invalid iMinorVer.
- * @param iMinorVer The minor version number of the debug info format.
- * -1 when iMajorVer is -1.
- * @param pszPartNm The name of the debug info part, NULL if not
- * applicable.
- * @param offFile The file offset *if* this type has one specific
- * location in the executable image file. This is -1
- * if there isn't any specific file location.
- * @param LinkAddress The link address of the debug info if it's
- * loadable. NIL_RTLDRADDR if not loadable.
- * @param cb The size of the debug information. -1 is used if
- * this isn't applicable.
- * @param pszExtFile This points to the name of an external file
- * containing the debug info. This is NULL if there
- * isn't any external file.
+ * @param pDbgInfo Pointer to a read only structure with the details.
* @param pvUser The user parameter specified to RTLdrEnumDbgInfo.
*/
-typedef DECLCALLBACK(int) FNRTLDRENUMDBG(RTLDRMOD hLdrMod, uint32_t iDbgInfo, RTLDRDBGINFOTYPE enmType,
- uint16_t iMajorVer, uint16_t iMinorVer, const char *pszPartNm,
- RTFOFF offFile, RTLDRADDR LinkAddress, RTLDRADDR cb,
- const char *pszExtFile, void *pvUser);
+typedef DECLCALLBACK(int) FNRTLDRENUMDBG(RTLDRMOD hLdrMod, PCRTLDRDBGINFO pDbgInfo, void *pvUser);
/** Pointer to a debug info enumerator callback. */
typedef FNRTLDRENUMDBG *PFNRTLDRENUMDBG;
@@ -424,8 +664,8 @@ RTDECL(int) RTLdrEnumDbgInfo(RTLDRMOD hLdrMod, const void *pvBits, PFNRTLDRENUMD
*/
typedef struct RTLDRSEG
{
- /** The segment name. (Might not be zero terminated!) */
- const char *pchName;
+ /** The segment name. Always set to something. */
+ const char *pszName;
/** The length of the segment name. */
uint32_t cchName;
/** The flat selector to use for the segment (i.e. data/code).
@@ -551,6 +791,43 @@ RTDECL(int) RTLdrSegOffsetToRva(RTLDRMOD hLdrMod, uint32_t iSeg, RTLDRADDR offSe
*/
RTDECL(int) RTLdrRvaToSegOffset(RTLDRMOD hLdrMod, RTLDRADDR Rva, uint32_t *piSeg, PRTLDRADDR poffSeg);
+/**
+ * Gets the image format.
+ *
+ * @returns Valid image format on success. RTLDRFMT_INVALID on invalid handle or
+ * other errors.
+ * @param hLdrMod The module handle.
+ */
+RTDECL(RTLDRFMT) RTLdrGetFormat(RTLDRMOD hLdrMod);
+
+/**
+ * Gets the image type.
+ *
+ * @returns Valid image type value on success. RTLDRTYPE_INVALID on
+ * invalid handle or other errors.
+ * @param hLdrMod The module handle.
+ */
+RTDECL(RTLDRTYPE) RTLdrGetType(RTLDRMOD hLdrMod);
+
+/**
+ * Gets the image endian-ness.
+ *
+ * @returns Valid image endian value on success. RTLDRENDIAN_INVALID on invalid
+ * handle or other errors.
+ * @param hLdrMod The module handle.
+ */
+RTDECL(RTLDRENDIAN) RTLdrGetEndian(RTLDRMOD hLdrMod);
+
+/**
+ * Gets the image endian-ness.
+ *
+ * @returns Valid image architecture value on success.
+ * RTLDRARCH_INVALID on invalid handle or other errors.
+ * @param hLdrMod The module handle.
+ */
+RTDECL(RTLDRARCH) RTLdrGetArch(RTLDRMOD hLdrMod);
+
+
RT_C_DECLS_END
/** @} */
diff --git a/include/iprt/ldrlazy.h b/include/iprt/ldrlazy.h
new file mode 100644
index 00000000..addfa36e
--- /dev/null
+++ b/include/iprt/ldrlazy.h
@@ -0,0 +1,102 @@
+/** @file
+ * IPRT - Lazy share library linking (2nd try).
+ */
+
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef ___iprt_ldrlazy_h
+#define ___iprt_ldrlazy_h
+
+#include <iprt/ldr.h>
+
+/** @defgroup grp_rt_ldrlazy Lazy shared library linking.
+ * @ingroup grp_rt
+ *
+ *
+ * @{
+ */
+
+
+/**
+ * Defines a module for use in lazy resolving.
+ *
+ * @param a_Mod The module name (C name).
+ * @param a_pszFile The file to tell RTLdrLoad to load.
+ */
+#define RTLDRLAZY_MODULE(a_Mod, a_pszFile) \
+ RTLDRLAZY_MODULE_EX(a_Mod, a_pszFile, RTLdrLoad)
+
+/**
+ * Defines a module for use in lazy resolving.
+ *
+ * @param a_Mod The module name (C name).
+ * @param a_pszFile The file to tell RTLdrLoad to load.
+ * @param a_pfnLoadIt Function to call for loading the DLL, replacing
+ * RTLdrLoad.
+ */
+#define RTLDRLAZY_MODULE_EX(a_Mod, a_pszFile, a_pfnLoadIt) \
+ static bool rtLdrLazy_##a_Mod##_Resolve(const char *pszName, void **ppvSymbol) \
+ { \
+ static RTLDRMOD volatile s_hMod = NIL_RTLDRMOD; \
+ static bool volatile s_fLoaded = false; \
+ RTLDRMOD hMod; \
+ int rc; \
+ if (!s_fLoaded) \
+ { \
+ rc = a_pfnLoadIt(a_pszFile, &hMod); \
+ s_hMod = RT_SUCCESS(rc) ? hMod : NIL_RTLDRMOD; \
+ s_fLoaded = true; \
+ if (RT_FAILURE(rc)) \
+ return false; \
+ } \
+ hMod = s_hMod; \
+ if (hMod == NIL_RTLDRMOD) \
+ return false; \
+ rc = RTLdrGetSymbol(hMod, pszName, ppvSymbol); \
+ return RT_SUCCESS(rc); \
+ }
+
+
+
+/** Function name mangler for preventing collision with system prototypes. */
+#define RTLDRLAZY_FUNC_NAME(a_Mod, a_Name) a_Mod##__##a_Name
+
+/**
+ * Defines a function that should be lazily resolved.
+ */
+#define RTLDRLAZY_FUNC(a_Mod, a_RetType, a_CallConv, a_Name, a_ParamDecl, a_ParamNames, a_ErrRet) \
+ DECLINLINE(a_RetType) RTLDRLAZY_FUNC_NAME(a_Mod, a_Name) a_ParamDecl \
+ { \
+ static a_RetType (a_CallConv * s_pfn) a_ParamDecl; \
+ if (!s_pfn) \
+ { \
+ if (!rtLdrLazy_##a_Mod##_Resolve(#a_Name, (void **)&s_pfn)) \
+ return a_ErrRet; \
+ } \
+ return s_pfn a_ParamNames; \
+ }
+
+
+/** @} */
+
+#endif
+
diff --git a/include/iprt/linux/sysfs.h b/include/iprt/linux/sysfs.h
index 27010af4..c4862799 100644
--- a/include/iprt/linux/sysfs.h
+++ b/include/iprt/linux/sysfs.h
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-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;
diff --git a/include/iprt/list.h b/include/iprt/list.h
index 1a4a4bc0..929b3180 100644
--- a/include/iprt/list.h
+++ b/include/iprt/list.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-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;
@@ -183,6 +183,9 @@ DECLINLINE(void) RTListNodeRemove(PRTLISTNODE pNode)
*/
#define RTListNodeIsDummy(pList, pNode, Type, Member) \
( (pNode) == RT_FROM_MEMBER((pList), Type, Member) )
+/** @copydoc RTListNodeIsDummy */
+#define RTListNodeIsDummyCpp(pList, pNode, Type, Member) \
+ ( (pNode) == RT_FROM_CPP_MEMBER((pList), Type, Member) )
/**
* Checks if a list is empty.
@@ -205,6 +208,9 @@ DECLINLINE(void) RTListNodeRemove(PRTLISTNODE pNode)
*/
#define RTListNodeGetNext(pCurNode, Type, Member) \
RT_FROM_MEMBER((pCurNode)->pNext, Type, Member)
+/** @copydoc RTListNodeGetNext */
+#define RTListNodeGetNextCpp(pCurNode, Type, Member) \
+ RT_FROM_CPP_MEMBER((pCurNode)->pNext, Type, Member)
/**
* Returns the previous node in the list.
@@ -217,6 +223,9 @@ DECLINLINE(void) RTListNodeRemove(PRTLISTNODE pNode)
*/
#define RTListNodeGetPrev(pCurNode, Type, Member) \
RT_FROM_MEMBER((pCurNode)->pPrev, Type, Member)
+/** @copydoc RTListNodeGetPrev */
+#define RTListNodeGetPrevCpp(pCurNode, Type, Member) \
+ RT_FROM_CPP_MEMBER((pCurNode)->pPrev, Type, Member)
/**
* Returns the first element in the list (checks for empty list).
@@ -230,6 +239,9 @@ DECLINLINE(void) RTListNodeRemove(PRTLISTNODE pNode)
*/
#define RTListGetFirst(pList, Type, Member) \
(!RTListIsEmpty(pList) ? RTListNodeGetNext(pList, Type, Member) : NULL)
+/** @copydoc RTListGetFirst */
+#define RTListGetFirstCpp(pList, Type, Member) \
+ (!RTListIsEmpty(pList) ? RTListNodeGetNextCpp(pList, Type, Member) : NULL)
/**
* Returns the last element in the list (checks for empty list).
@@ -243,6 +255,9 @@ DECLINLINE(void) RTListNodeRemove(PRTLISTNODE pNode)
*/
#define RTListGetLast(pList, Type, Member) \
(!RTListIsEmpty(pList) ? RTListNodeGetPrev(pList, Type, Member) : NULL)
+/** @copydoc RTListGetLast */
+#define RTListGetLastCpp(pList, Type, Member) \
+ (!RTListIsEmpty(pList) ? RTListNodeGetPrevCpp(pList, Type, Member) : NULL)
/**
* Returns the next node in the list or NULL if the end has been reached.
@@ -256,6 +271,9 @@ DECLINLINE(void) RTListNodeRemove(PRTLISTNODE pNode)
*/
#define RTListGetNext(pList, pCurNode, Type, Member) \
( (pCurNode)->Member.pNext != (pList) ? RT_FROM_MEMBER((pCurNode)->Member.pNext, Type, Member) : NULL )
+/** @copydoc RTListGetNext */
+#define RTListGetNextCpp(pList, pCurNode, Type, Member) \
+ ( (pCurNode)->Member.pNext != (pList) ? RT_FROM_CPP_MEMBER((pCurNode)->Member.pNext, Type, Member) : NULL )
/**
* Returns the previous node in the list or NULL if the start has been reached.
@@ -269,6 +287,9 @@ DECLINLINE(void) RTListNodeRemove(PRTLISTNODE pNode)
*/
#define RTListGetPrev(pList, pCurNode, Type, Member) \
( (pCurNode)->Member.pPrev != (pList) ? RT_FROM_MEMBER((pCurNode)->Member.pPrev, Type, Member) : NULL )
+/** @copydoc RTListGetPrev */
+#define RTListGetPrevCpp(pList, pCurNode, Type, Member) \
+ ( (pCurNode)->Member.pPrev != (pList) ? RT_FROM_CPP_MEMBER((pCurNode)->Member.pPrev, Type, Member) : NULL )
/**
* Enumerate the list in head to tail order.
@@ -282,6 +303,11 @@ DECLINLINE(void) RTListNodeRemove(PRTLISTNODE pNode)
for (pIterator = RTListNodeGetNext(pList, Type, Member); \
!RTListNodeIsDummy(pList, pIterator, Type, Member); \
pIterator = RT_FROM_MEMBER((pIterator)->Member.pNext, Type, Member) )
+/** @copydoc RTListForEach */
+#define RTListForEachCpp(pList, pIterator, Type, Member) \
+ for (pIterator = RTListNodeGetNextCpp(pList, Type, Member); \
+ !RTListNodeIsDummyCpp(pList, pIterator, Type, Member); \
+ pIterator = RT_FROM_CPP_MEMBER((pIterator)->Member.pNext, Type, Member) )
/**
@@ -301,6 +327,13 @@ DECLINLINE(void) RTListNodeRemove(PRTLISTNODE pNode)
!RTListNodeIsDummy(pList, pIterator, Type, Member); \
pIterator = pIterNext, \
pIterNext = RT_FROM_MEMBER((pIterator)->Member.pNext, Type, Member) )
+/** @copydoc RTListForEachSafe */
+#define RTListForEachSafeCpp(pList, pIterator, pIterNext, Type, Member) \
+ for (pIterator = RTListNodeGetNextCpp(pList, Type, Member), \
+ pIterNext = RT_FROM_CPP_MEMBER((pIterator)->Member.pNext, Type, Member); \
+ !RTListNodeIsDummyCpp(pList, pIterator, Type, Member); \
+ pIterator = pIterNext, \
+ pIterNext = RT_FROM_CPP_MEMBER((pIterator)->Member.pNext, Type, Member) )
/**
@@ -315,6 +348,11 @@ DECLINLINE(void) RTListNodeRemove(PRTLISTNODE pNode)
for (pIterator = RTListNodeGetPrev(pList, Type, Member); \
!RTListNodeIsDummy(pList, pIterator, Type, Member); \
pIterator = RT_FROM_MEMBER((pIterator)->Member.pPrev, Type, Member) )
+/** @copydoc RTListForEachReverse */
+#define RTListForEachReverseCpp(pList, pIterator, Type, Member) \
+ for (pIterator = RTListNodeGetPrevCpp(pList, Type, Member); \
+ !RTListNodeIsDummyCpp(pList, pIterator, Type, Member); \
+ pIterator = RT_FROM_CPP_MEMBER((pIterator)->Member.pPrev, Type, Member) )
/**
@@ -333,6 +371,13 @@ DECLINLINE(void) RTListNodeRemove(PRTLISTNODE pNode)
!RTListNodeIsDummy(pList, pIterator, Type, Member); \
pIterator = pIterPrev, \
pIterPrev = RT_FROM_MEMBER((pIterator)->Member.pPrev, Type, Member) )
+/** @copydoc RTListForEachReverseSafe */
+#define RTListForEachReverseSafeCpp(pList, pIterator, pIterPrev, Type, Member) \
+ for (pIterator = RTListNodeGetPrevCpp(pList, Type, Member), \
+ pIterPrev = RT_FROM_CPP_MEMBER((pIterator)->Member.pPrev, Type, Member); \
+ !RTListNodeIsDummyCpp(pList, pIterator, Type, Member); \
+ pIterator = pIterPrev, \
+ pIterPrev = RT_FROM_CPP_MEMBER((pIterator)->Member.pPrev, Type, Member) )
/**
diff --git a/include/iprt/localipc.h b/include/iprt/localipc.h
index 0a887e42..37196626 100644
--- a/include/iprt/localipc.h
+++ b/include/iprt/localipc.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -75,7 +75,7 @@ RTDECL(int) RTLocalIpcServerCreate(PRTLOCALIPCSERVER phServer, const char *pszNa
/** @name RTLocalIpcServerCreate flags
* @{ */
-/** The server can handle multiple session. */
+/** The server can handle multiple sessions. */
#define RTLOCALIPC_FLAGS_MULTI_SESSION RT_BIT_32(0)
/** The mask of valid flags. */
#define RTLOCALIPC_FLAGS_VALID_MASK UINT32_C(0x00000001)
@@ -150,7 +150,7 @@ RTDECL(int) RTLocalIpcSessionClose(RTLOCALIPCSESSION hSession);
* @param hSession The session handle.
* @param pvBuffer Where to store the data.
* @param cbBuffer If pcbRead is non-NULL this indicates the maximum number of
- * bytes to read. If pcbRead is NULL the this is the exact number
+ * bytes to read. If pcbRead is NULL then this is the exact number
* of bytes to read.
* @param pcbRead Optional argument for indicating a partial read and returning
* the number of bytes actually read.
@@ -188,7 +188,7 @@ RTDECL(int) RTLocalIpcSessionWrite(RTLOCALIPCSESSION hSession, const void *pvBuf
RTDECL(int) RTLocalIpcSessionFlush(RTLOCALIPCSESSION hSession);
/**
- * Wait for data to become read for reading or for the
+ * Wait for data to become ready for reading or for the
* session to be disconnected.
*
* @returns IPRT status code.
diff --git a/include/iprt/lockvalidator.h b/include/iprt/lockvalidator.h
index 7e0f08c1..b088b1e9 100644
--- a/include/iprt/lockvalidator.h
+++ b/include/iprt/lockvalidator.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-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;
@@ -102,9 +102,6 @@ AssertCompileSize(RTLOCKVALSRCPOS, HC_ARCH_BITS == 32 ? 16 : 32);
#define RTLOCKVALSRCPOS_INIT_POS_NO_ID() \
RTLOCKVALSRCPOS_INIT(pszFile, iLine, pszFunction, (uintptr_t)ASMReturnAddress())
-/** Pointer to a record of one ownership share. */
-typedef struct RTLOCKVALRECSHRD *PRTLOCKVALRECSHRD;
-
/**
* Lock validator record core.
@@ -568,6 +565,7 @@ RTDECL(int) RTLockValidatorRecExclCheckOrderAndBlocking(PRTLOCKVALRECEXCL pRec,
*/
RTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
void *hLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, ...);
+
/**
* Initialize a lock validator record for a shared lock.
*
@@ -592,6 +590,7 @@ RTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS
*/
RTDECL(void) RTLockValidatorRecSharedInitV(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
void *hLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, va_list va);
+
/**
* Uninitialize a lock validator record previously initialized by
* RTLockValidatorRecSharedInit.
@@ -601,6 +600,68 @@ RTDECL(void) RTLockValidatorRecSharedInitV(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLAS
RTDECL(void) RTLockValidatorRecSharedDelete(PRTLOCKVALRECSHRD pRec);
/**
+ * Create and initialize a lock validator record for a shared lock.
+ *
+ * Use RTLockValidatorRecSharedDestroy to deinitialize and destroy the returned
+ * record.
+ *
+ * @returns IPRT status code.
+ * @param ppRec Where to return the record pointer.
+ * @param hClass The class (no reference consumed). If NIL, the
+ * no lock order validation will be performed on
+ * this lock.
+ * @param uSubClass The sub-class. This is used to define lock
+ * order inside the same class. If you don't know,
+ * then pass RTLOCKVAL_SUB_CLASS_NONE.
+ * @param pvLock The lock handle or address.
+ * @param fSignaller Set if event semaphore signaller logic should be
+ * applied to this record, clear if read-write
+ * semaphore logic should be used.
+ * @param fEnabled Pass @c false to explicitly disable lock
+ * validation, otherwise @c true.
+ * @param pszNameFmt Name format string for the lock validator,
+ * optional (NULL). Max length is 32 bytes.
+ * @param ... Format string arguments.
+ */
+RTDECL(int) RTLockValidatorRecSharedCreate(PRTLOCKVALRECSHRD *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
+ void *pvLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, ...);
+
+/**
+ * Create and initialize a lock validator record for a shared lock.
+ *
+ * Use RTLockValidatorRecSharedDestroy to deinitialize and destroy the returned
+ * record.
+ *
+ * @returns IPRT status code.
+ * @param ppRec Where to return the record pointer.
+ * @param hClass The class (no reference consumed). If NIL, the
+ * no lock order validation will be performed on
+ * this lock.
+ * @param uSubClass The sub-class. This is used to define lock
+ * order inside the same class. If you don't know,
+ * then pass RTLOCKVAL_SUB_CLASS_NONE.
+ * @param pvLock The lock handle or address.
+ * @param fSignaller Set if event semaphore signaller logic should be
+ * applied to this record, clear if read-write
+ * semaphore logic should be used.
+ * @param fEnabled Pass @c false to explicitly disable lock
+ * validation, otherwise @c true.
+ * @param pszNameFmt Name format string for the lock validator,
+ * optional (NULL). Max length is 32 bytes.
+ * @param va Format string arguments.
+ */
+RTDECL(int) RTLockValidatorRecSharedCreateV(PRTLOCKVALRECSHRD *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
+ void *pvLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, va_list va);
+
+/**
+ * Deinitialize and destroy a record created by RTLockValidatorRecSharedCreate.
+ *
+ * @param ppRec Pointer to the record pointer. Will be set to
+ * NULL.
+ */
+RTDECL(void) RTLockValidatorRecSharedDestroy(PRTLOCKVALRECSHRD *ppRec);
+
+/**
* Sets the sub-class of the record.
*
* It is recommended to try make sure that nobody is using this class while
diff --git a/include/iprt/log.h b/include/iprt/log.h
index cce17079..427eebc8 100644
--- a/include/iprt/log.h
+++ b/include/iprt/log.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2011 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -705,6 +705,22 @@ RTDECL(void) RTLogPrintfEx(void *pvInstance, unsigned fFlags, unsigned iGroup, c
do { Log((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log(a); } while (0)
#endif
+/** @def Log4Func
+ * Level 4 logging inside C/C++ functions.
+ *
+ * Prepends the given log message with the function name followed by a
+ * semicolon and space.
+ *
+ * @param a Log message in format <tt>("string\n" [, args])</tt>.
+ */
+#ifdef LOG_USE_C99
+# define Log4Func(a) \
+ _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
+#else
+# define Log4Func(a) \
+ do { Log((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log(a); } while (0)
+#endif
+
/** @def LogThisFunc
* The same as LogFunc but for class functions (methods): the resulting log
* line is additionally prepended with a hex value of |this| pointer.
diff --git a/include/iprt/mangling.h b/include/iprt/mangling.h
index cc8b4ec6..58c9e94d 100644
--- a/include/iprt/mangling.h
+++ b/include/iprt/mangling.h
@@ -10,7 +10,7 @@
*/
/*
- * Copyright (C) 2011-2012 Oracle Corporation
+ * Copyright (C) 2011-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -55,8 +55,22 @@
# define ASMAtomicReadU64_EndProc RT_MANGLER(ASMAtomicReadU64_EndProc)
# define ASMAtomicUoReadU64 RT_MANGLER(ASMAtomicUoReadU64) /* not-some-systems... */
# define ASMAtomicUoReadU64_EndProc RT_MANGLER(ASMAtomicUoReadU64_EndProc)
+# define ASMAtomicUoAndU64 RT_MANGLER(ASMAtomicUoAndU64) /* not-some-systems... */
+# define ASMAtomicUoAndU64_EndProc RT_MANGLER(ASMAtomicUoAndU64_EndProc)
+# define ASMAtomicUoAndU32 RT_MANGLER(ASMAtomicUoAndU32) /* not-some-systems... */
+# define ASMAtomicUoAndU32_EndProc RT_MANGLER(ASMAtomicUoAndU32_EndProc)
+# define ASMAtomicUoOrU64 RT_MANGLER(ASMAtomicUoOrU64) /* not-some-systems... */
+# define ASMAtomicUoOrU64_EndProc RT_MANGLER(ASMAtomicUoOrU64_EndProc)
+# define ASMAtomicUoOrU32 RT_MANGLER(ASMAtomicUoOrU32) /* not-some-systems... */
+# define ASMAtomicUoOrU32_EndProc RT_MANGLER(ASMAtomicUoOrU32_EndProc)
# define ASMAtomicXchgU64 RT_MANGLER(ASMAtomicXchgU64) /* not-some-systems... */
# define ASMAtomicXchgU64_EndProc RT_MANGLER(ASMAtomicXchgU64_EndProc)
+# define ASMRdMsrEx RT_MANGLER(ASMRdMsrEx)
+# define ASMRdMsrEx_EndProc RT_MANGLER(ASMRdMsrEx_EndProc)
+# define ASMWrMsrEx RT_MANGLER(ASMWrMsrEx)
+# define ASMWrMsrEx_EndProc RT_MANGLER(ASMWrMsrEx_EndProc)
+# define ASMCpuIdExSlow RT_MANGLER(ASMCpuIdExSlow)
+# define ASMCpuIdExSlow_EndProc RT_MANGLER(ASMCpuIdExSlow_EndProc)
# define RTAssertAreQuiet RT_MANGLER(RTAssertAreQuiet)
# define RTAssertMayPanic RT_MANGLER(RTAssertMayPanic)
# define RTAssertMsg1 RT_MANGLER(RTAssertMsg1)
@@ -324,6 +338,25 @@
# define RTCritSectSetSubClass RT_MANGLER(RTCritSectSetSubClass)
# define RTCritSectTryEnter RT_MANGLER(RTCritSectTryEnter)
# define RTCritSectTryEnterDebug RT_MANGLER(RTCritSectTryEnterDebug)
+# define RTCritSectRwDelete RT_MANGLER(RTCritSectRwDelete)
+# define RTCritSectRwEnterExcl RT_MANGLER(RTCritSectRwEnterExcl)
+# define RTCritSectRwEnterExclDebug RT_MANGLER(RTCritSectRwEnterExclDebug)
+# define RTCritSectRwEnterShared RT_MANGLER(RTCritSectRwEnterShared)
+# define RTCritSectRwEnterSharedDebug RT_MANGLER(RTCritSectRwEnterSharedDebug)
+# define RTCritSectRwGetReadCount RT_MANGLER(RTCritSectRwGetReadCount)
+# define RTCritSectRwGetWriteRecursion RT_MANGLER(RTCritSectRwGetWriteRecursion)
+# define RTCritSectRwGetWriterReadRecursion RT_MANGLER(RTCritSectRwGetWriterReadRecursion)
+# define RTCritSectRwInit RT_MANGLER(RTCritSectRwInit)
+# define RTCritSectRwInitEx RT_MANGLER(RTCritSectRwInitEx)
+# define RTCritSectRwIsReadOwner RT_MANGLER(RTCritSectRwIsReadOwner)
+# define RTCritSectRwIsWriteOwner RT_MANGLER(RTCritSectRwIsWriteOwner)
+# define RTCritSectRwLeaveExcl RT_MANGLER(RTCritSectRwLeaveExcl)
+# define RTCritSectRwLeaveShared RT_MANGLER(RTCritSectRwLeaveShared)
+# define RTCritSectRwSetSubClass RT_MANGLER(RTCritSectRwSetSubClass)
+# define RTCritSectRwTryEnterExcl RT_MANGLER(RTCritSectRwTryEnterExcl)
+# define RTCritSectRwTryEnterExclDebug RT_MANGLER(RTCritSectRwTryEnterExclDebug)
+# define RTCritSectRwTryEnterShared RT_MANGLER(RTCritSectRwTryEnterShared)
+# define RTCritSectRwTryEnterSharedDebug RT_MANGLER(RTCritSectRwTryEnterSharedDebug)
# define RTDbgAsCreate RT_MANGLER(RTDbgAsCreate)
# define RTDbgAsCreateF RT_MANGLER(RTDbgAsCreateF)
# define RTDbgAsCreateV RT_MANGLER(RTDbgAsCreateV)
@@ -332,6 +365,7 @@
# define RTDbgAsLineAdd RT_MANGLER(RTDbgAsLineAdd)
# define RTDbgAsLineByAddr RT_MANGLER(RTDbgAsLineByAddr)
# define RTDbgAsLineByAddrA RT_MANGLER(RTDbgAsLineByAddrA)
+# define RTDbgAsLockExcl RT_MANGLER(RTDbgAsLockExcl)
# define RTDbgAsModuleByAddr RT_MANGLER(RTDbgAsModuleByAddr)
# define RTDbgAsModuleByIndex RT_MANGLER(RTDbgAsModuleByIndex)
# define RTDbgAsModuleByName RT_MANGLER(RTDbgAsModuleByName)
@@ -349,15 +383,35 @@
# define RTDbgAsSymbolByAddrA RT_MANGLER(RTDbgAsSymbolByAddrA)
# define RTDbgAsSymbolByName RT_MANGLER(RTDbgAsSymbolByName)
# define RTDbgAsSymbolByNameA RT_MANGLER(RTDbgAsSymbolByNameA)
+# define RTDbgAsUnlockExcl RT_MANGLER(RTDbgAsUnlockExcl)
+# define RTDbgCfgCreate RT_MANGLER(RTDbgCfgCreate)
+# define RTDbgCfgRetain RT_MANGLER(RTDbgCfgRetain)
+# define RTDbgCfgRelease RT_MANGLER(RTDbgCfgRelease)
+# define RTDbgCfgChangeString RT_MANGLER(RTDbgCfgChangeString)
+# define RTDbgCfgChangeUInt RT_MANGLER(RTDbgCfgChangeUInt)
+# define RTDbgCfgQueryString RT_MANGLER(RTDbgCfgQueryString)
+# define RTDbgCfgQueryUInt RT_MANGLER(RTDbgCfgQueryUInt)
+# define RTDbgCfgOpenDbg RT_MANGLER(RTDbgCfgOpenDbg)
+# define RTDbgCfgOpenDsymBundle RT_MANGLER(RTDbgCfgOpenDsymBundle)
+# define RTDbgCfgOpenDwo RT_MANGLER(RTDbgCfgOpenDwo)
+# define RTDbgCfgOpenPdb70 RT_MANGLER(RTDbgCfgOpenPdb70)
+# define RTDbgCfgOpenPdb20 RT_MANGLER(RTDbgCfgOpenPdb20)
+# define RTDbgCfgOpenPeImage RT_MANGLER(RTDbgCfgOpenPeImage)
+# define RTDbgCfgSetLogCallback RT_MANGLER(RTDbgCfgSetLogCallback)
# define RTDbgLineAlloc RT_MANGLER(RTDbgLineAlloc)
# define RTDbgLineDup RT_MANGLER(RTDbgLineDup)
# define RTDbgLineFree RT_MANGLER(RTDbgLineFree)
# define RTDbgModCreate RT_MANGLER(RTDbgModCreate)
-# define RTDbgModCreateDeferred RT_MANGLER(RTDbgModCreateDeferred)
+# define RTDbgModCreateFromDbg RT_MANGLER(RTDbgModCreateFromDbg)
+# define RTDbgModCreateFromDwo RT_MANGLER(RTDbgModCreateFromDwo)
# define RTDbgModCreateFromImage RT_MANGLER(RTDbgModCreateFromImage)
# define RTDbgModCreateFromMap RT_MANGLER(RTDbgModCreateFromMap)
+# define RTDbgModCreateFromPdb RT_MANGLER(RTDbgModCreateFromPdb)
+# define RTDbgModCreateFromPeImage RT_MANGLER(RTDbgModCreateFromPeImage)
# define RTDbgModGetTag RT_MANGLER(RTDbgModGetTag)
# define RTDbgModImageSize RT_MANGLER(RTDbgModImageSize)
+# define RTDbgModIsDeferred RT_MANGLER(RTDbgModIsDeferred)
+# define RTDbgModIsExports RT_MANGLER(RTDbgModIsExports)
# define RTDbgModLineAdd RT_MANGLER(RTDbgModLineAdd)
# define RTDbgModLineByAddr RT_MANGLER(RTDbgModLineByAddr)
# define RTDbgModLineByAddrA RT_MANGLER(RTDbgModLineByAddrA)
@@ -365,7 +419,11 @@
# define RTDbgModLineByOrdinalA RT_MANGLER(RTDbgModLineByOrdinalA)
# define RTDbgModLineCount RT_MANGLER(RTDbgModLineCount)
# define RTDbgModName RT_MANGLER(RTDbgModName)
+# define RTDbgModDebugFile RT_MANGLER(RTDbgModDebugFile)
+# define RTDbgModImageFile RT_MANGLER(RTDbgModImageFile)
+# define RTDbgModImageFileUsed RT_MANGLER(RTDbgModImageFileUsed)
# define RTDbgModRelease RT_MANGLER(RTDbgModRelease)
+# define RTDbgModRemoveAll RT_MANGLER(RTDbgModRemoveAll)
# define RTDbgModRetain RT_MANGLER(RTDbgModRetain)
# define RTDbgModRvaToSegOff RT_MANGLER(RTDbgModRvaToSegOff)
# define RTDbgModSegmentAdd RT_MANGLER(RTDbgModSegmentAdd)
@@ -391,12 +449,16 @@
# define RTDirCreateTemp RT_MANGLER(RTDirCreateTemp)
# define RTDirCreateTempSecure RT_MANGLER(RTDirCreateTempSecure)
# define RTDirCreateUniqueNumbered RT_MANGLER(RTDirCreateUniqueNumbered)
+# define RTDirEntryIsStdDotLink RT_MANGLER(RTDirEntryIsStdDotLink)
+# define RTDirEntryExIsStdDotLink RT_MANGLER(RTDirEntryExIsStdDotLink)
# define RTDirExists RT_MANGLER(RTDirExists)
# define RTDirFlush RT_MANGLER(RTDirFlush)
# define RTDirFlushParent RT_MANGLER(RTDirFlushParent)
# define RTDirOpen RT_MANGLER(RTDirOpen)
# define RTDirOpenFiltered RT_MANGLER(RTDirOpenFiltered)
# define RTDirQueryInfo RT_MANGLER(RTDirQueryInfo)
+# define RTDirQueryUnknownType RT_MANGLER(RTDirQueryUnknownType)
+# define RTDirQueryUnknownTypeEx RT_MANGLER(RTDirQueryUnknownTypeEx)
# define RTDirRead RT_MANGLER(RTDirRead)
# define RTDirReadEx RT_MANGLER(RTDirReadEx)
# define RTDirRemove RT_MANGLER(RTDirRemove)
@@ -430,17 +492,27 @@
# define RTEnvDestroy RT_MANGLER(RTEnvDestroy)
# define RTEnvDupEx RT_MANGLER(RTEnvDupEx)
# define RTEnvExist RT_MANGLER(RTEnvExist)
+# define RTEnvExistsBad RT_MANGLER(RTEnvExistsBad)
+# define RTEnvExistsUtf8 RT_MANGLER(RTEnvExistsUtf8)
# define RTEnvExistEx RT_MANGLER(RTEnvExistEx)
# define RTEnvFreeUtf16Block RT_MANGLER(RTEnvFreeUtf16Block)
# define RTEnvGet RT_MANGLER(RTEnvGet)
+# define RTEnvGetBad RT_MANGLER(RTEnvGetBad)
+# define RTEnvGetUtf8 RT_MANGLER(RTEnvGetUtf8)
# define RTEnvGetEx RT_MANGLER(RTEnvGetEx)
# define RTEnvGetExecEnvP RT_MANGLER(RTEnvGetExecEnvP)
# define RTEnvPut RT_MANGLER(RTEnvPut)
+# define RTEnvPutBad RT_MANGLER(RTEnvPutBad)
+# define RTEnvPutUtf8 RT_MANGLER(RTEnvPutUtf8)
# define RTEnvPutEx RT_MANGLER(RTEnvPutEx)
# define RTEnvQueryUtf16Block RT_MANGLER(RTEnvQueryUtf16Block)
# define RTEnvSet RT_MANGLER(RTEnvSet)
+# define RTEnvSetBad RT_MANGLER(RTEnvSetBad)
+# define RTEnvSetUtf8 RT_MANGLER(RTEnvSetUtf8)
# define RTEnvSetEx RT_MANGLER(RTEnvSetEx)
# define RTEnvUnset RT_MANGLER(RTEnvUnset)
+# define RTEnvUnsetBad RT_MANGLER(RTEnvUnsetBad)
+# define RTEnvUnsetUtf8 RT_MANGLER(RTEnvUnsetUtf8)
# define RTEnvUnsetEx RT_MANGLER(RTEnvUnsetEx)
# define RTErrCOMGet RT_MANGLER(RTErrCOMGet)
# define RTErrConvertFromErrno RT_MANGLER(RTErrConvertFromErrno)
@@ -490,6 +562,8 @@
# define RTFileIoCtl RT_MANGLER(RTFileIoCtl)
# define RTFileIsValid RT_MANGLER(RTFileIsValid)
# define RTFileLock RT_MANGLER(RTFileLock)
+# define RTFileModeToFlags RT_MANGLER(RTFileModeToFlags)
+# define RTFileModeToFlagsEx RT_MANGLER(RTFileModeToFlagsEx)
# define RTFileMove RT_MANGLER(RTFileMove)
# define RTFileOpen RT_MANGLER(RTFileOpen)
# define RTFileOpenBitBucket RT_MANGLER(RTFileOpenBitBucket)
@@ -509,8 +583,11 @@
# define RTFileSeek RT_MANGLER(RTFileSeek)
# define RTFileSetForceFlags RT_MANGLER(RTFileSetForceFlags)
# define RTFileSetMode RT_MANGLER(RTFileSetMode)
+# define RTFileSetOwner RT_MANGLER(RTFileSetOwner)
# define RTFileSetSize RT_MANGLER(RTFileSetSize)
# define RTFileSetTimes RT_MANGLER(RTFileSetTimes)
+# define RTFileSgReadAt RT_MANGLER(RTFileSgReadAt)
+# define RTFileSgWriteAt RT_MANGLER(RTFileSgWriteAt)
# define RTFileTell RT_MANGLER(RTFileTell)
# define RTFileToNative RT_MANGLER(RTFileToNative)
# define RTFileUnlock RT_MANGLER(RTFileUnlock)
@@ -558,6 +635,8 @@
# define RTHeapSimpleInit RT_MANGLER(RTHeapSimpleInit)
# define RTHeapSimpleRelocate RT_MANGLER(RTHeapSimpleRelocate)
# define RTHeapSimpleSize RT_MANGLER(RTHeapSimpleSize)
+# define RTHttpGetFile RT_MANGLER(RTHttpGetFile)
+# define RTHttpUseSystemProxySettings RT_MANGLER(RTHttpUseSystemProxySettings)
# define RTIsoFsClose RT_MANGLER(RTIsoFsClose)
# define RTIsoFsExtractFile RT_MANGLER(RTIsoFsExtractFile)
# define RTIsoFsGetFileInfo RT_MANGLER(RTIsoFsGetFileInfo)
@@ -574,17 +653,26 @@
# define RTLdrEnumDbgInfo RT_MANGLER(RTLdrEnumDbgInfo)
# define RTLdrEnumSegments RT_MANGLER(RTLdrEnumSegments)
# define RTLdrEnumSymbols RT_MANGLER(RTLdrEnumSymbols)
+# define RTLdrGetArch RT_MANGLER(RTLdrGetArch)
# define RTLdrGetBits RT_MANGLER(RTLdrGetBits)
+# define RTLdrGetEndian RT_MANGLER(RTLdrGetEndian)
+# define RTLdrGetFormat RT_MANGLER(RTLdrGetFormat)
+# define RTLdrGetFunction RT_MANGLER(RTLdrGetFunction)
+# define RTLdrGetNativeHandle RT_MANGLER(RTLdrGetNativeHandle)
# define RTLdrGetSuff RT_MANGLER(RTLdrGetSuff)
# define RTLdrGetSymbol RT_MANGLER(RTLdrGetSymbol)
# define RTLdrGetSymbolEx RT_MANGLER(RTLdrGetSymbolEx)
+# define RTLdrGetSystemSymbol RT_MANGLER(RTLdrGetSystemSymbol)
+# define RTLdrGetType RT_MANGLER(RTLdrGetType)
# define RTLdrIsLoadable RT_MANGLER(RTLdrIsLoadable)
# define RTLdrLinkAddressToRva RT_MANGLER(RTLdrLinkAddressToRva)
# define RTLdrLinkAddressToSegOffset RT_MANGLER(RTLdrLinkAddressToSegOffset)
# define RTLdrLoad RT_MANGLER(RTLdrLoad)
# define RTLdrLoadAppPriv RT_MANGLER(RTLdrLoadAppPriv)
# define RTLdrLoadEx RT_MANGLER(RTLdrLoadEx)
+# define RTLdrLoadSystem RT_MANGLER(RTLdrLoadSystem)
# define RTLdrOpen RT_MANGLER(RTLdrOpen)
+# define RTLdrOpenInMemory RT_MANGLER(RTLdrOpenInMemory)
# define RTLdrOpenkLdr RT_MANGLER(RTLdrOpenkLdr)
# define RTLdrRelocate RT_MANGLER(RTLdrRelocate)
# define RTLdrRvaToSegOffset RT_MANGLER(RTLdrRvaToSegOffset)
@@ -651,7 +739,10 @@
# define RTLockValidatorRecSharedCheckOrder RT_MANGLER(RTLockValidatorRecSharedCheckOrder)
# define RTLockValidatorRecSharedCheckOrderAndBlocking RT_MANGLER(RTLockValidatorRecSharedCheckOrderAndBlocking)
# define RTLockValidatorRecSharedCheckSignaller RT_MANGLER(RTLockValidatorRecSharedCheckSignaller)
+# define RTLockValidatorRecSharedCreate RT_MANGLER(RTLockValidatorRecSharedCreate)
+# define RTLockValidatorRecSharedCreateV RT_MANGLER(RTLockValidatorRecSharedCreateV)
# define RTLockValidatorRecSharedDelete RT_MANGLER(RTLockValidatorRecSharedDelete)
+# define RTLockValidatorRecSharedDestroy RT_MANGLER(RTLockValidatorRecSharedDestroy)
# define RTLockValidatorRecSharedInit RT_MANGLER(RTLockValidatorRecSharedInit)
# define RTLockValidatorRecSharedInitV RT_MANGLER(RTLockValidatorRecSharedInitV)
# define RTLockValidatorRecSharedIsOwner RT_MANGLER(RTLockValidatorRecSharedIsOwner)
@@ -737,6 +828,7 @@
# define RTManifestSetAttr RT_MANGLER(RTManifestSetAttr)
# define RTManifestUnsetAttr RT_MANGLER(RTManifestUnsetAttr)
# define RTManifestVerify RT_MANGLER(RTManifestVerify)
+# define RTManifestVerifyDigestType RT_MANGLER(RTManifestVerifyDigestType)
# define RTManifestVerifyFiles RT_MANGLER(RTManifestVerifyFiles)
# define RTManifestVerifyFilesBuf RT_MANGLER(RTManifestVerifyFilesBuf)
# define RTManifestWriteFiles RT_MANGLER(RTManifestWriteFiles)
@@ -749,7 +841,7 @@
# define RTMd5Init RT_MANGLER(RTMd5Init)
# define RTMd5ToString RT_MANGLER(RTMd5ToString)
# define RTMd5Update RT_MANGLER(RTMd5Update)
-# define RTMemAllocExTag RT_MANGLER(RTMemAllocExTag) /* r0drv */
+# define RTMemAllocExTag RT_MANGLER(RTMemAllocExTag)
# define RTMemAllocTag RT_MANGLER(RTMemAllocTag)
# define RTMemAllocVarTag RT_MANGLER(RTMemAllocVarTag)
# define RTMemAllocZTag RT_MANGLER(RTMemAllocZTag)
@@ -789,7 +881,7 @@
# define RTMemExecAllocTag RT_MANGLER(RTMemExecAllocTag)
# define RTMemExecFree RT_MANGLER(RTMemExecFree)
# define RTMemFree RT_MANGLER(RTMemFree)
-# define RTMemFreeEx RT_MANGLER(RTMemFreeEx) /* r0drv */
+# define RTMemFreeEx RT_MANGLER(RTMemFreeEx)
# define RTMemPageAllocTag RT_MANGLER(RTMemPageAllocTag)
# define RTMemPageAllocZTag RT_MANGLER(RTMemPageAllocZTag)
# define RTMemPageFree RT_MANGLER(RTMemPageFree)
@@ -834,10 +926,13 @@
# define RTMpGetMaxCpuId RT_MANGLER(RTMpGetMaxCpuId)
# define RTMpGetMaxFrequency RT_MANGLER(RTMpGetMaxFrequency)
# define RTMpGetOnlineCount RT_MANGLER(RTMpGetOnlineCount)
+# define RTMpGetOnlineCoreCount RT_MANGLER(RTMpGetOnlineCoreCount)
# define RTMpGetOnlineSet RT_MANGLER(RTMpGetOnlineSet)
# define RTMpGetPresentCount RT_MANGLER(RTMpGetPresentCount)
+# define RTMpGetPresentCoreCount RT_MANGLER(RTMpGetPresentCoreCount)
# define RTMpGetPresentSet RT_MANGLER(RTMpGetPresentSet)
# define RTMpGetSet RT_MANGLER(RTMpGetSet)
+# define RTMpGetCoreCount RT_MANGLER(RTMpGetCoreCount)
# define RTMpIsCpuOnline RT_MANGLER(RTMpIsCpuOnline)
# define RTMpIsCpuPossible RT_MANGLER(RTMpIsCpuPossible) /* r0drv */
# define RTMpIsCpuPresent RT_MANGLER(RTMpIsCpuPresent)
@@ -880,7 +975,9 @@
# define RTNetIPv6PseudoChecksumEx RT_MANGLER(RTNetIPv6PseudoChecksumEx)
# define RTNetTCPChecksum RT_MANGLER(RTNetTCPChecksum)
# define RTNetUDPChecksum RT_MANGLER(RTNetUDPChecksum)
+# define RTNetStrToMacAddr RT_MANGLER(RTNetStrToMacAddr)
# define RTNetIsIPv4AddrStr RT_MANGLER(RTNetIsIPv4AddrStr)
+# define RTNetStrToIPv4Addr RT_MANGLER(RTNetStrToIPv4Addr)
# define RTNetIsIPv6AddrStr RT_MANGLER(RTNetIsIPv6AddrStr)
# define RTOnceSlow RT_MANGLER(RTOnceSlow)
# define RTOnceReset RT_MANGLER(RTOnceReset)
@@ -894,6 +991,7 @@
# define RTPathAppPrivateArch RT_MANGLER(RTPathAppPrivateArch)
# define RTPathAppPrivateArchTop RT_MANGLER(RTPathAppPrivateArchTop)
# define RTPathAppPrivateNoArch RT_MANGLER(RTPathAppPrivateNoArch)
+# define RTPathCalcRelative RT_MANGLER(RTPathCalcRelative)
# define RTPathChangeToDosSlashes RT_MANGLER(RTPathChangeToDosSlashes)
# define RTPathChangeToUnixSlashes RT_MANGLER(RTPathChangeToUnixSlashes)
# define RTPathCompare RT_MANGLER(RTPathCompare)
@@ -904,19 +1002,24 @@
# define RTPathExistsEx RT_MANGLER(RTPathExistsEx)
# define RTPathExt RT_MANGLER(RTPathExt)
# define RTPathFilename RT_MANGLER(RTPathFilename)
+# define RTPathFilenameEx RT_MANGLER(RTPathFilenameEx)
# define RTPathGetCurrent RT_MANGLER(RTPathGetCurrent)
# define RTPathGetMode RT_MANGLER(RTPathGetMode)
# define RTPathHasExt RT_MANGLER(RTPathHasExt)
# define RTPathHasPath RT_MANGLER(RTPathHasPath)
+# define RTPathIsSame RT_MANGLER(RTPathIsSame)
# define RTPathJoin RT_MANGLER(RTPathJoin)
# define RTPathJoinA RT_MANGLER(RTPathJoinA)
# define RTPathJoinEx RT_MANGLER(RTPathJoinEx)
# define RTPathParse RT_MANGLER(RTPathParse)
+# define RTPathParsedReassemble RT_MANGLER(RTPathParsedReassemble)
+# define RTPathParseSimple RT_MANGLER(RTPathParseSimple)
# define RTPathQueryInfo RT_MANGLER(RTPathQueryInfo)
# define RTPathQueryInfoEx RT_MANGLER(RTPathQueryInfoEx)
# define RTPathReal RT_MANGLER(RTPathReal)
# define RTPathRealDup RT_MANGLER(RTPathRealDup)
# define RTPathRename RT_MANGLER(RTPathRename)
+# define RTPathRmCmd RT_MANGLER(RTPathRmCmd)
# define RTPathSetCurrent RT_MANGLER(RTPathSetCurrent)
# define RTPathSetMode RT_MANGLER(RTPathSetMode) /* not-win */
# define RTPathSetOwner RT_MANGLER(RTPathSetOwner) /* not-win */
@@ -924,6 +1027,10 @@
# define RTPathSetTimes RT_MANGLER(RTPathSetTimes)
# define RTPathSetTimesEx RT_MANGLER(RTPathSetTimesEx)
# define RTPathSharedLibs RT_MANGLER(RTPathSharedLibs)
+# define RTPathSplit RT_MANGLER(RTPathSplit)
+# define RTPathSplitATag RT_MANGLER(RTPathSplitATag)
+# define RTPathSplitFree RT_MANGLER(RTPathSplitFree)
+# define RTPathSplitReassemble RT_MANGLER(RTPathSplitReassemble)
# define RTPathStartsWith RT_MANGLER(RTPathStartsWith)
# define RTPathStartsWithRoot RT_MANGLER(RTPathStartsWithRoot)
# define RTPathStripExt RT_MANGLER(RTPathStripExt)
@@ -1018,6 +1125,7 @@
# define RTR3InitExe RT_MANGLER(RTR3InitExe)
# define RTR3InitExeNoArguments RT_MANGLER(RTR3InitExeNoArguments)
# define RTR3InitEx RT_MANGLER(RTR3InitEx)
+# define RTR3InitIsUnobtrusive RT_MANGLER(RTR3InitIsUnobtrusive)
# define rtR3MemAlloc RT_MANGLER(rtR3MemAlloc)
# define rtR3MemFree RT_MANGLER(rtR3MemFree)
# define rtR3MemRealloc RT_MANGLER(rtR3MemRealloc)
@@ -1172,6 +1280,7 @@
# define RTSgBufCopyFromBuf RT_MANGLER(RTSgBufCopyFromBuf)
# define RTSgBufCopyToBuf RT_MANGLER(RTSgBufCopyToBuf)
# define RTSgBufInit RT_MANGLER(RTSgBufInit)
+# define RTSgBufIsZero RT_MANGLER(RTSgBufIsZero)
# define RTSgBufReset RT_MANGLER(RTSgBufReset)
# define RTSgBufSegArrayCreate RT_MANGLER(RTSgBufSegArrayCreate)
# define RTSgBufSet RT_MANGLER(RTSgBufSet)
@@ -1190,6 +1299,8 @@
# define RTSha256Init RT_MANGLER(RTSha256Init)
# define RTSha256ToString RT_MANGLER(RTSha256ToString)
# define RTSha256Update RT_MANGLER(RTSha256Update)
+# define RTSha256Digest RT_MANGLER(RTSha256Digest)
+# define RTSha256DigestFromFile RT_MANGLER(RTSha256DigestFromFile)
# define RTSha512 RT_MANGLER(RTSha512)
# define RTSha512Final RT_MANGLER(RTSha512Final)
# define RTSha512FromString RT_MANGLER(RTSha512FromString)
@@ -1241,7 +1352,11 @@
# define RTStrCacheCreate RT_MANGLER(RTStrCacheCreate)
# define RTStrCacheDestroy RT_MANGLER(RTStrCacheDestroy)
# define RTStrCacheEnter RT_MANGLER(RTStrCacheEnter)
+# define RTStrCacheEnterLower RT_MANGLER(RTStrCacheEnterLower)
+# define RTStrCacheEnterLowerN RT_MANGLER(RTStrCacheEnterLowerN)
# define RTStrCacheEnterN RT_MANGLER(RTStrCacheEnterN)
+# define RTStrCacheGetStats RT_MANGLER(RTStrCacheGetStats)
+# define RTStrCacheIsRealImpl RT_MANGLER(RTStrCacheIsRealImpl)
# define RTStrCacheLength RT_MANGLER(RTStrCacheLength)
# define RTStrCacheRelease RT_MANGLER(RTStrCacheRelease)
# define RTStrCacheRetain RT_MANGLER(RTStrCacheRetain)
@@ -1286,6 +1401,9 @@
# define RTStrHash1N RT_MANGLER(RTStrHash1N)
# define RTStrICmp RT_MANGLER(RTStrICmp)
# define RTStrIStr RT_MANGLER(RTStrIStr)
+# define RTStrIsCaseFoldable RT_MANGLER(RTStrIsCaseFoldable)
+# define RTStrIsLowerCased RT_MANGLER(RTStrIsLowerCased)
+# define RTStrIsUpperCased RT_MANGLER(RTStrIsUpperCased)
# define RTStrIsValidEncoding RT_MANGLER(RTStrIsValidEncoding)
# define RTStrmClearError RT_MANGLER(RTStrmClearError)
# define RTStrmClose RT_MANGLER(RTStrmClose)
@@ -1407,9 +1525,11 @@
# define RTTarList RT_MANGLER(RTTarList)
# define RTTarOpen RT_MANGLER(RTTarOpen)
# define RTTarSeekNextFile RT_MANGLER(RTTarSeekNextFile)
+# define RTTcpClientCancelConnect RT_MANGLER(RTTcpClientCancelConnect)
# define RTTcpClientClose RT_MANGLER(RTTcpClientClose)
# define RTTcpClientCloseEx RT_MANGLER(RTTcpClientCloseEx)
# define RTTcpClientConnect RT_MANGLER(RTTcpClientConnect)
+# define RTTcpClientConnectEx RT_MANGLER(RTTcpClientConnectEx)
# define RTTcpFlush RT_MANGLER(RTTcpFlush)
# define RTTcpGetLocalAddress RT_MANGLER(RTTcpGetLocalAddress)
# define RTTcpGetPeerAddress RT_MANGLER(RTTcpGetPeerAddress)
@@ -1438,7 +1558,9 @@
# define RTTermRegisterCallback RT_MANGLER(RTTermRegisterCallback)
# define RTTermRunCallbacks RT_MANGLER(RTTermRunCallbacks)
# define RTTestBanner RT_MANGLER(RTTestBanner)
+# define RTTestChangeName RT_MANGLER(RTTestChangeName)
# define RTTestCreate RT_MANGLER(RTTestCreate)
+# define RTTestCreateEx RT_MANGLER(RTTestCreateEx)
# define RTTestDestroy RT_MANGLER(RTTestDestroy)
# define RTTestErrorCount RT_MANGLER(RTTestErrorCount)
# define RTTestErrorInc RT_MANGLER(RTTestErrorInc)
@@ -1459,6 +1581,7 @@
# define RTTestIFailureDetails RT_MANGLER(RTTestIFailureDetails)
# define RTTestIFailureDetailsV RT_MANGLER(RTTestIFailureDetailsV)
# define RTTestInitAndCreate RT_MANGLER(RTTestInitAndCreate)
+# define RTTestInitExAndCreate RT_MANGLER(RTTestInitExAndCreate)
# define RTTestIPassed RT_MANGLER(RTTestIPassed)
# define RTTestIPassedV RT_MANGLER(RTTestIPassedV)
# define RTTestIPrintf RT_MANGLER(RTTestIPrintf)
@@ -1479,8 +1602,11 @@
# define RTTestSetDefault RT_MANGLER(RTTestSetDefault)
# define RTTestSkipAndDestroy RT_MANGLER(RTTestSkipAndDestroy)
# define RTTestSkipAndDestroyV RT_MANGLER(RTTestSkipAndDestroyV)
+# define RTTestSkipped RT_MANGLER(RTTestSkipped)
+# define RTTestSkippedV RT_MANGLER(RTTestSkippedV)
# define RTTestSub RT_MANGLER(RTTestSub)
# define RTTestSubDone RT_MANGLER(RTTestSubDone)
+# define RTTestSubErrorCount RT_MANGLER(RTTestSubErrorCount)
# define RTTestSubF RT_MANGLER(RTTestSubF)
# define RTTestSubV RT_MANGLER(RTTestSubV)
# define RTTestSummaryAndDestroy RT_MANGLER(RTTestSummaryAndDestroy)
@@ -1492,6 +1618,12 @@
# define RTThreadCreate RT_MANGLER(RTThreadCreate)
# define RTThreadCreateF RT_MANGLER(RTThreadCreateF)
# define RTThreadCreateV RT_MANGLER(RTThreadCreateV)
+# define RTThreadCtxHooksAreRegistered RT_MANGLER(RTThreadCtxHooksAreRegistered) /* r0drv */
+# define RTThreadCtxHooksCreate RT_MANGLER(RTThreadCtxHooksCreate) /* r0drv */
+# define RTThreadCtxHooksDeregister RT_MANGLER(RTThreadCtxHooksDeregister) /* r0drv */
+# define RTThreadCtxHooksRegister RT_MANGLER(RTThreadCtxHooksRegister) /* r0drv */
+# define RTThreadCtxHooksRelease RT_MANGLER(RTThreadCtxHooksRelease) /* r0drv */
+# define RTThreadCtxHooksRetain RT_MANGLER(RTThreadCtxHooksRetain) /* r0drv */
# define RTThreadFromNative RT_MANGLER(RTThreadFromNative)
# define RTThreadGetAffinity RT_MANGLER(RTThreadGetAffinity)
# define RTThreadGetExecutionTimeMilli RT_MANGLER(RTThreadGetExecutionTimeMilli)
@@ -1572,9 +1704,11 @@
# define RTTimerStart RT_MANGLER(RTTimerStart)
# define RTTimerStop RT_MANGLER(RTTimerStop)
# define RTTimeSet RT_MANGLER(RTTimeSet)
+# define RTTimeSpecFromString RT_MANGLER(RTTimeSpecFromString)
# define RTTimeSpecToString RT_MANGLER(RTTimeSpecToString)
# define RTTimeSystemMilliTS RT_MANGLER(RTTimeSystemMilliTS)
# define RTTimeSystemNanoTS RT_MANGLER(RTTimeSystemNanoTS)
+# define RTTimeFromString RT_MANGLER(RTTimeFromString)
# define RTTimeToString RT_MANGLER(RTTimeToString)
# define RTTlsAlloc RT_MANGLER(RTTlsAlloc)
# define RTTlsAllocEx RT_MANGLER(RTTlsAllocEx)
@@ -1666,6 +1800,7 @@
# define RTVfsFileFromRTFile RT_MANGLER(RTVfsFileFromRTFile)
# define RTVfsFileGetSize RT_MANGLER(RTVfsFileGetSize)
# define RTVfsFileOpen RT_MANGLER(RTVfsFileOpen)
+# define RTVfsFileOpenNormal RT_MANGLER(RTVfsFileOpenNormal)
# define RTVfsFilePoll RT_MANGLER(RTVfsFilePoll)
# define RTVfsFileQueryInfo RT_MANGLER(RTVfsFileQueryInfo)
# define RTVfsFileRead RT_MANGLER(RTVfsFileRead)
@@ -1686,6 +1821,7 @@
# define RTVfsIoStrmFromRTFile RT_MANGLER(RTVfsIoStrmFromRTFile)
# define RTVfsIoStrmFromStdHandle RT_MANGLER(RTVfsIoStrmFromStdHandle)
# define RTVfsIoStrmIsAtEnd RT_MANGLER(RTVfsIoStrmIsAtEnd)
+# define RTVfsIoStrmOpenNormal RT_MANGLER(RTVfsIoStrmOpenNormal)
# define RTVfsIoStrmPoll RT_MANGLER(RTVfsIoStrmPoll)
# define RTVfsIoStrmQueryInfo RT_MANGLER(RTVfsIoStrmQueryInfo)
# define RTVfsIoStrmRead RT_MANGLER(RTVfsIoStrmRead)
@@ -1754,10 +1890,11 @@
# define RTZipDecompCreate RT_MANGLER(RTZipDecompCreate)
# define RTZipDecompDestroy RT_MANGLER(RTZipDecompDestroy)
# define RTZipDecompress RT_MANGLER(RTZipDecompress)
+# define RTZipGzipCompressIoStream RT_MANGLER(RTZipGzipCompressIoStream)
# define RTZipGzipDecompressIoStream RT_MANGLER(RTZipGzipDecompressIoStream)
# define RTZipTarCmd RT_MANGLER(RTZipTarCmd)
# define RTZipTarFsStreamFromIoStream RT_MANGLER(RTZipTarFsStreamFromIoStream)
-
+# define RTZipXarFsStreamFromIoStream RT_MANGLER(RTZipXarFsStreamFromIoStream)
/*
* Stable variables (alphabetical order):
*/
diff --git a/include/iprt/manifest.h b/include/iprt/manifest.h
index f7092b2a..d40f601e 100644
--- a/include/iprt/manifest.h
+++ b/include/iprt/manifest.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -60,18 +60,22 @@ RT_C_DECLS_BEGIN
/** @name Digest types. */
typedef enum RTDIGESTTYPE
{
- /** CRC32 checksum */
- RTDIGESTTYPE_CRC32 = 1,
- /** CRC64 checksum */
+ /** Invalid digest value. */
+ RTDIGESTTYPE_INVALID = 0,
+ /** CRC32 checksum. */
+ RTDIGESTTYPE_CRC32,
+ /** CRC64 checksum. */
RTDIGESTTYPE_CRC64,
- /** MD5 checksum (unsafe!) */
+ /** MD5 checksum (unsafe!). */
RTDIGESTTYPE_MD5,
- /** SHA1 checksum (unsafe!) */
+ /** SHA1 checksum (unsafe!). */
RTDIGESTTYPE_SHA1,
- /** SHA256 checksum */
+ /** SHA256 checksum. */
RTDIGESTTYPE_SHA256,
- /** SHA512 checksum */
- RTDIGESTTYPE_SHA512
+ /** SHA512 checksum. */
+ RTDIGESTTYPE_SHA512,
+ /** Usual 32-bit type blowup. */
+ RTDIGESTTYPE_32BIT_HACK = 0x7fffffff
} RTDIGESTTYPE;
/** @} */
@@ -445,6 +449,7 @@ typedef RTMANIFESTTEST* PRTMANIFESTTEST;
* @param piFailed A index to paTests in the
* VERR_MANIFEST_DIGEST_MISMATCH error case
* (optional).
+ * @deprecated Use the RTMANIFEST based API instead.
*/
RTR3DECL(int) RTManifestVerify(const char *pszManifestFile, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed);
@@ -462,6 +467,7 @@ RTR3DECL(int) RTManifestVerify(const char *pszManifestFile, PRTMANIFESTTEST paTe
* (optional).
* @param pfnProgressCallback optional callback for the progress indication
* @param pvUser user defined pointer for the callback
+ * @deprecated Use the RTMANIFEST based API instead.
*/
RTR3DECL(int) RTManifestVerifyFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles, size_t *piFailed,
PFNRTPROGRESS pfnProgressCallback, void *pvUser);
@@ -479,12 +485,26 @@ RTR3DECL(int) RTManifestVerifyFiles(const char *pszManifestFile, const char * co
* @param cFiles Number of entries in papszFiles.
* @param pfnProgressCallback optional callback for the progress indication
* @param pvUser user defined pointer for the callback
+ * @deprecated Use the RTMANIFEST based API instead.
*/
RTR3DECL(int) RTManifestWriteFiles(const char *pszManifestFile, RTDIGESTTYPE enmDigestType,
const char * const *papszFiles, size_t cFiles,
PFNRTPROGRESS pfnProgressCallback, void *pvUser);
/**
+ * Queries the first digest type found in the given manifest.
+ *
+ * @returns iprt status code.
+ *
+ * @param pvBuf Pointer to memory buffer of the manifest file.
+ * @param cbSize Size of the memory buffer.
+ * @param penmDigestType Where to return the first digest type found in
+ * the manifest.
+ * @deprecated Use the RTMANIFEST based API instead.
+ */
+RTR3DECL(int) RTManifestVerifyDigestType(void const *pvBuf, size_t cbSize, RTDIGESTTYPE *penmDigestType);
+
+/**
* Verify the given SHA1 digests against the entries in the manifest file in
* memory.
*
@@ -497,6 +517,7 @@ RTR3DECL(int) RTManifestWriteFiles(const char *pszManifestFile, RTDIGESTTYPE enm
* @param piFailed A index to paTests in the
* VERR_MANIFEST_DIGEST_MISMATCH error case
* (optional).
+ * @deprecated Use the RTMANIFEST based API instead.
*/
RTR3DECL(int) RTManifestVerifyFilesBuf(void *pvBuf, size_t cbSize, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed);
@@ -512,6 +533,7 @@ RTR3DECL(int) RTManifestVerifyFilesBuf(void *pvBuf, size_t cbSize, PRTMANIFESTTE
* @param enmDigestType Which type of digest ("SHA1", "SHA256", ...)
* @param paFiles Array of file names and digests.
* @param cFiles Number of entries in paFiles.
+ * @deprecated Use the RTMANIFEST based API instead.
*/
RTR3DECL(int) RTManifestWriteFilesBuf(void **ppvBuf, size_t *pcbSize, RTDIGESTTYPE enmDigestType, PRTMANIFESTTEST paFiles, size_t cFiles);
diff --git a/include/iprt/md5.h b/include/iprt/md5.h
index e085abb6..f9f48320 100644
--- a/include/iprt/md5.h
+++ b/include/iprt/md5.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/mem.h b/include/iprt/mem.h
index 883de0fe..9b868065 100644
--- a/include/iprt/mem.h
+++ b/include/iprt/mem.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2011 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -313,8 +313,16 @@ RTDECL(void) RTMemFree(void *pv) RT_NO_THROW;
/** Allocate and free from any context.
* Will return VERR_NOT_SUPPORTED if not supported. */
#define RTMEMALLOCEX_FLAGS_ANY_CTX (RTMEMALLOCEX_FLAGS_ANY_CTX_ALLOC | RTMEMALLOCEX_FLAGS_ANY_CTX_FREE)
+/** Reachable by 16-bit address.
+ * Will return VERR_NOT_SUPPORTED if not supported. */
+#define RTMEMALLOCEX_FLAGS_16BIT_REACH RT_BIT(4)
+/** Reachable by 32-bit address.
+ * Will return VERR_NOT_SUPPORTED if not supported. */
+#define RTMEMALLOCEX_FLAGS_32BIT_REACH RT_BIT(5)
/** Mask of valid flags. */
-#define RTMEMALLOCEX_FLAGS_VALID_MASK UINT32_C(0x0000000f)
+#define RTMEMALLOCEX_FLAGS_VALID_MASK UINT32_C(0x0000003f)
+/** Mask of valid flags for ring-0. */
+#define RTMEMALLOCEX_FLAGS_VALID_MASK_R0 UINT32_C(0x0000000f)
/** @} */
/**
@@ -337,6 +345,9 @@ RTDECL(void) RTMemFree(void *pv) RT_NO_THROW;
/**
* Extended heap allocation API, custom tag.
*
+ * Depending on the implementation, using this function may add extra overhead,
+ * so use the simpler APIs where ever possible.
+ *
* @returns IPRT status code.
* @retval VERR_NO_MEMORY if we're out of memory.
* @retval VERR_NO_EXEC_MEMORY if we're out of executable memory.
@@ -357,6 +368,11 @@ RTDECL(int) RTMemAllocExTag(size_t cb, size_t cbAlignment, uint32_t fFlags, cons
*
* @param pv What to free, NULL is fine.
* @param cb The amount of allocated memory.
+ * @param fFlags The flags specified when allocating the memory.
+ * Whether the exact flags are requires depends on
+ * the implementation, but in general, ring-0
+ * doesn't require anything while ring-3 requires
+ * RTMEMALLOCEX_FLAGS_EXEC if used.
*/
RTDECL(void) RTMemFreeEx(void *pv, size_t cb) RT_NO_THROW;
diff --git a/include/iprt/memcache.h b/include/iprt/memcache.h
index cad496b1..6cf8c2a5 100644
--- a/include/iprt/memcache.h
+++ b/include/iprt/memcache.h
@@ -37,7 +37,17 @@ RT_C_DECLS_BEGIN
* @ingroup grp_rt
*
* Optimized allocation, initialization, freeing and destruction of memory
- * objects of the same kind and size.
+ * objects of the same kind and size. Objects are constructed once, then
+ * allocated and freed one or more times, until finally destructed together with
+ * the cache (RTMemCacheDestroy). It's expected behavior, even when pfnCtor is
+ * NULL, that the user will be store information that should be persistent
+ * across RTMemCacheFree calls.
+ *
+ * The objects are zeroed prior to calling pfnCtor. For obvious reasons, the
+ * objects are not touched by the cache after that, so that RTMemCacheAlloc will
+ * return the object in the same state as when it as handed to RTMemCacheFree.
+ *
+ * @todo A callback for the reuse (at alloc time) might be of interest.
*
* @{
*/
diff --git a/include/iprt/memobj.h b/include/iprt/memobj.h
index 3a3b7025..b4498380 100644
--- a/include/iprt/memobj.h
+++ b/include/iprt/memobj.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2010 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;
diff --git a/include/iprt/mempool.h b/include/iprt/mempool.h
index 6be563d3..22943342 100644
--- a/include/iprt/mempool.h
+++ b/include/iprt/mempool.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-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;
diff --git a/include/iprt/memtracker.h b/include/iprt/memtracker.h
index 5d557b20..ca22fec5 100644
--- a/include/iprt/memtracker.h
+++ b/include/iprt/memtracker.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-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;
diff --git a/include/iprt/message.h b/include/iprt/message.h
index b70a79be..1d78f176 100644
--- a/include/iprt/message.h
+++ b/include/iprt/message.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-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;
diff --git a/include/iprt/mp.h b/include/iprt/mp.h
index 70c0bf5e..23ababc3 100644
--- a/include/iprt/mp.h
+++ b/include/iprt/mp.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-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;
@@ -116,6 +116,13 @@ RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet);
*/
RTDECL(RTCPUID) RTMpGetCount(void);
+/**
+ * Get the count of physical CPU cores present in the system plus any that may
+ * possibly be hotplugged later.
+ *
+ * @returns The number of cores.
+ */
+RTDECL(RTCPUID) RTMpGetCoreCount(void);
/**
* Gets set of the CPUs present that are currently online.
@@ -133,6 +140,14 @@ RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet);
RTDECL(RTCPUID) RTMpGetOnlineCount(void);
/**
+ * Get the count of physical CPU cores in the system with one or more online
+ * threads.
+ *
+ * @returns The number of online cores.
+ */
+RTDECL(RTCPUID) RTMpGetOnlineCoreCount(void);
+
+/**
* Checks if a CPU is online or not.
*
* @returns true/false accordingly.
@@ -157,6 +172,13 @@ RTDECL(PRTCPUSET) RTMpGetPresentSet(PRTCPUSET pSet);
RTDECL(RTCPUID) RTMpGetPresentCount(void);
/**
+ * Get the count of physical CPU cores present in the system.
+ *
+ * @returns The number of cores.
+ */
+RTDECL(RTCPUID) RTMpGetPresentCoreCount(void);
+
+/**
* Checks if a CPU is present in the system.
*
* @returns true/false accordingly.
diff --git a/include/iprt/net.h b/include/iprt/net.h
index 38e066b9..14c32f8b 100644
--- a/include/iprt/net.h
+++ b/include/iprt/net.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2008-2012 Oracle Corporation
+ * Copyright (C) 2008-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -39,6 +39,19 @@ RT_C_DECLS_BEGIN
*/
/**
+ * Converts an stringified Ethernet MAC address into the RTMAC representation.
+ *
+ * @todo This should be move to some generic part of the runtime.
+ *
+ * @returns VINF_SUCCESS on success, VERR_GETOPT_INVALID_ARGUMENT_FORMAT on
+ * failure.
+ *
+ * @param pszValue The value to convert.
+ * @param pAddr Where to store the result.
+ */
+RTDECL(int) RTNetStrToMacAddr(const char *pszAddr, PRTMAC pMacAddr);
+
+/**
* IPv4 address.
*/
typedef RTUINT32U RTNETADDRIPV4;
@@ -56,6 +69,17 @@ typedef RTNETADDRIPV4 const *PCRTNETADDRIPV4;
*/
RTDECL(bool) RTNetIsIPv4AddrStr(const char *pszAddress);
+/**
+ * Converts an stringified IPv4 address into the RTNETADDRIPV4 representation.
+ *
+ * @returns VINF_SUCCESS on success, VERR_INVALID_PARAMETER on
+ * failure.
+ *
+ * @param pszAddr The value to convert.
+ * @param pAddr Where to store the result.
+ */
+RTDECL(int) RTNetStrToIPv4Addr(const char *pszAddr, PRTNETADDRIPV4 pAddr);
+
/**
* IPv6 address.
@@ -323,7 +347,8 @@ typedef RTNETIPV6 const *PCRTNETIPV6;
/** The minimum IPv6 header length (in bytes).
* Up to and including RTNETIPV6::ip6_dst. */
-#define RTNETIPV6_MIN_LEN (40)
+#define RTNETIPV6_MIN_LEN (40)
+#define RTNETIPV6_ICMPV6_ND_WITH_LLA_OPT_MIN_LEN (32)
RTDECL(uint32_t) RTNetIPv6PseudoChecksum(PCRTNETIPV6 pIpHdr);
RTDECL(uint32_t) RTNetIPv6PseudoChecksumEx(PCRTNETIPV6 pIpHdr, uint8_t bProtocol, uint16_t cbPkt);
@@ -737,6 +762,51 @@ typedef RTNETICMPV4 const *PCRTNETICMPV4;
/** @todo add ICMPv6 when needed. */
+#define RTNETIPV6_PROT_ICMPV6 (58)
+#define RTNETIPV6_ICMPV6_CODE_0 (0)
+#define RTNETIPV6_ICMP_NS_TYPE (135)
+#define RTNETIPV6_ICMP_NA_TYPE (136)
+#define RTNETIPV6_ICMP_ND_SLLA_OPT (1)
+#define RTNETIPV6_ICMP_ND_TLLA_OPT (2)
+#define RTNETIPV6_ICMP_ND_LLA_LEN (1)
+
+/** ICMPv6 ND Source Link Layer Address option */
+#pragma pack(1)
+typedef struct RTNETNDP_SLLA_OPT
+{
+ uint8_t type;
+ uint8_t len;
+ RTMAC slla;
+} RTNETNDP_SLLA_OPT;
+#pragma pack()
+
+AssertCompileSize(RTNETNDP_SLLA_OPT, 1+1+6);
+
+typedef RTNETNDP_SLLA_OPT *PRTNETNDP_SLLA_OPT;
+typedef RTNETNDP_SLLA_OPT const *PCRTNETNDP_SLLA_OPT;
+
+/** ICMPv6 ND Neighbor Sollicitation */
+#pragma pack(1)
+typedef struct RTNETNDP
+{
+ /** ICMPv6 type. */
+ uint8_t icmp6_type;
+ /** ICMPv6 code. */
+ uint8_t icmp6_code;
+ /** ICMPv6 checksum */
+ uint16_t icmp6_cksum;
+ /** reserved */
+ uint32_t reserved;
+ /** target address */
+ RTNETADDRIPV6 target_address;
+} RTNETNDP;
+#pragma pack()
+AssertCompileSize(RTNETNDP, 1+1+2+4+16);
+/** Pointer to a NDP ND packet. */
+typedef RTNETNDP *PRTNETNDP;
+/** Pointer to a const NDP NS packet. */
+typedef RTNETNDP const *PCRTNETNDP;
+
/**
* Ethernet ARP header.
@@ -805,9 +875,6 @@ typedef RTNETARPIPV4 *PRTNETARPIPV4;
typedef RTNETARPIPV4 const *PCRTNETARPIPV4;
-/** @todo RTNETNDP (IPv6)*/
-
-
/** @} */
RT_C_DECLS_END
diff --git a/include/iprt/nocrt/amd64/fenv.h b/include/iprt/nocrt/amd64/fenv.h
index 002aa01f..0daf3e21 100644
--- a/include/iprt/nocrt/amd64/fenv.h
+++ b/include/iprt/nocrt/amd64/fenv.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/amd64/math.h b/include/iprt/nocrt/amd64/math.h
index 8d1e6536..762ac4f4 100644
--- a/include/iprt/nocrt/amd64/math.h
+++ b/include/iprt/nocrt/amd64/math.h
@@ -3,7 +3,7 @@
*/
/*
- * 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;
diff --git a/include/iprt/nocrt/compiler/compiler.h b/include/iprt/nocrt/compiler/compiler.h
index ea9f8952..77523d3c 100644
--- a/include/iprt/nocrt/compiler/compiler.h
+++ b/include/iprt/nocrt/compiler/compiler.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/compiler/gcc.h b/include/iprt/nocrt/compiler/gcc.h
index 890448b3..9aeb3ce6 100644
--- a/include/iprt/nocrt/compiler/gcc.h
+++ b/include/iprt/nocrt/compiler/gcc.h
@@ -7,7 +7,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/compiler/msc.h b/include/iprt/nocrt/compiler/msc.h
index 1fbb3a14..6ee0003c 100644
--- a/include/iprt/nocrt/compiler/msc.h
+++ b/include/iprt/nocrt/compiler/msc.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/fenv.h b/include/iprt/nocrt/fenv.h
index 32d8163c..710a6ee9 100644
--- a/include/iprt/nocrt/fenv.h
+++ b/include/iprt/nocrt/fenv.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/inttypes.h b/include/iprt/nocrt/inttypes.h
index dc42dbb4..b86ec08d 100644
--- a/include/iprt/nocrt/inttypes.h
+++ b/include/iprt/nocrt/inttypes.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/limits.h b/include/iprt/nocrt/limits.h
index 047f9644..2b377d16 100644
--- a/include/iprt/nocrt/limits.h
+++ b/include/iprt/nocrt/limits.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/math.h b/include/iprt/nocrt/math.h
index da37c5f6..568f17c1 100644
--- a/include/iprt/nocrt/math.h
+++ b/include/iprt/nocrt/math.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/setjmp.h b/include/iprt/nocrt/setjmp.h
index c7c7aaf0..9f61a955 100644
--- a/include/iprt/nocrt/setjmp.h
+++ b/include/iprt/nocrt/setjmp.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/stdarg.h b/include/iprt/nocrt/stdarg.h
index daa6e0a7..3e52e0c1 100644
--- a/include/iprt/nocrt/stdarg.h
+++ b/include/iprt/nocrt/stdarg.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/stddef.h b/include/iprt/nocrt/stddef.h
index 8487c26e..372f597d 100644
--- a/include/iprt/nocrt/stddef.h
+++ b/include/iprt/nocrt/stddef.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/stdlib.h b/include/iprt/nocrt/stdlib.h
index 9bfc1d2f..7332ac26 100644
--- a/include/iprt/nocrt/stdlib.h
+++ b/include/iprt/nocrt/stdlib.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/string.h b/include/iprt/nocrt/string.h
index 2ed2f72d..2ebee9b0 100644
--- a/include/iprt/nocrt/string.h
+++ b/include/iprt/nocrt/string.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/x86/fenv.h b/include/iprt/nocrt/x86/fenv.h
index 3a3db7da..8dc2c90d 100644
--- a/include/iprt/nocrt/x86/fenv.h
+++ b/include/iprt/nocrt/x86/fenv.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/nocrt/x86/math.h b/include/iprt/nocrt/x86/math.h
index 1d5dbed4..6ed0337c 100644
--- a/include/iprt/nocrt/x86/math.h
+++ b/include/iprt/nocrt/x86/math.h
@@ -3,7 +3,7 @@
*/
/*
- * 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;
diff --git a/include/iprt/once.h b/include/iprt/once.h
index 31afb739..63ee6f79 100644
--- a/include/iprt/once.h
+++ b/include/iprt/once.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -30,6 +30,7 @@
#include <iprt/types.h>
#include <iprt/asm.h>
#include <iprt/err.h>
+#include <iprt/list.h>
RT_C_DECLS_BEGIN
@@ -39,6 +40,28 @@ RT_C_DECLS_BEGIN
*/
/**
+ * Callback that gets executed once.
+ *
+ * @returns IPRT style status code, RTOnce returns this.
+ *
+ * @param pvUser The user parameter.
+ */
+typedef DECLCALLBACK(int32_t) FNRTONCE(void *pvUser);
+/** Pointer to a FNRTONCE. */
+typedef FNRTONCE *PFNRTONCE;
+
+/**
+ * Callback that gets executed on IPRT/process termination.
+ *
+ * @param pvUser The user parameter.
+ * @param fLazyCleanUpOk Indicates whether lazy clean-up is OK (see
+ * initterm.h).
+ */
+typedef DECLCALLBACK(void) FNRTONCECLEANUP(void *pvUser, bool fLazyCleanUpOk);
+/** Pointer to a FNRTONCE. */
+typedef FNRTONCECLEANUP *PFNRTONCECLEANUP;
+
+/**
* Execute once structure.
*
* This is typically a global variable that is statically initialized
@@ -47,13 +70,20 @@ RT_C_DECLS_BEGIN
typedef struct RTONCE
{
/** Event semaphore that the other guys are blocking on. */
- RTSEMEVENTMULTI volatile hEventMulti;
+ RTSEMEVENTMULTI volatile hEventMulti;
/** Reference counter for hEventMulti. */
- int32_t volatile cEventRefs;
- /** -1 when uninitialized, 1 when initializing (busy) and 2 when done. */
- int32_t volatile iState;
+ int32_t volatile cEventRefs;
+ /** See RTONCESTATE. */
+ int32_t volatile iState;
/** The return code of pfnOnce. */
- int32_t volatile rc;
+ int32_t volatile rc;
+
+ /** Pointer to the clean-up function. */
+ PFNRTONCECLEANUP pfnCleanUp;
+ /** Argument to hand to the clean-up function. */
+ void *pvUser;
+ /** Clean-up list entry. */
+ RTLISTNODE CleanUpNode;
} RTONCE;
/** Pointer to a execute once struct. */
typedef RTONCE *PRTONCE;
@@ -93,20 +123,24 @@ typedef enum RTONCESTATE
} RTONCESTATE;
/** Static initializer for RTONCE variables. */
-#define RTONCE_INITIALIZER { NIL_RTSEMEVENTMULTI, 0, RTONCESTATE_UNINITIALIZED, VERR_INTERNAL_ERROR }
+#define RTONCE_INITIALIZER \
+ { NIL_RTSEMEVENTMULTI, 0, RTONCESTATE_UNINITIALIZED, VERR_INTERNAL_ERROR, NULL, NULL, { NULL, NULL } }
/**
- * Callback that gets executed once.
+ * Serializes execution of the pfnOnce function, making sure it's
+ * executed exactly once and that nobody returns from RTOnce before
+ * it has executed successfully.
*
- * @returns IPRT style status code, RTOnce returns this.
+ * @returns IPRT like status code returned by pfnOnce.
*
- * @param pvUser1 The first user parameter.
- * @param pvUser2 The second user parameter.
+ * @param pOnce Pointer to the execute once variable.
+ * @param pfnOnce The function to executed once.
+ * @param pfnCleanUp The function that will be doing the cleaning up.
+ * Optional.
+ * @param pvUser The user parameter for pfnOnce.
*/
-typedef DECLCALLBACK(int32_t) FNRTONCE(void *pvUser1, void *pvUser2);
-/** Pointer to a FNRTONCE. */
-typedef FNRTONCE *PFNRTONCE;
+RTDECL(int) RTOnceSlow(PRTONCE pOnce, PFNRTONCE pfnOnce, FNRTONCECLEANUP pfnCleanUp, void *pvUser);
/**
* Serializes execution of the pfnOnce function, making sure it's
@@ -117,12 +151,21 @@ typedef FNRTONCE *PFNRTONCE;
*
* @param pOnce Pointer to the execute once variable.
* @param pfnOnce The function to executed once.
- * @param pvUser1 The first user parameter for pfnOnce.
- * @param pvUser2 The second user parameter for pfnOnce.
+ * @param pvUser The user parameter for pfnOnce.
*/
-RTDECL(int) RTOnceSlow(PRTONCE pOnce, PFNRTONCE pfnOnce, void *pvUser1, void *pvUser2);
+DECLINLINE(int) RTOnce(PRTONCE pOnce, PFNRTONCE pfnOnce, void *pvUser)
+{
+ int32_t iState = ASMAtomicUoReadS32(&pOnce->iState);
+ if (RT_LIKELY( iState == RTONCESTATE_DONE
+ || iState == RTONCESTATE_DONE_CREATING_SEM
+ || iState == RTONCESTATE_DONE_HAVE_SEM ))
+ return ASMAtomicUoReadS32(&pOnce->rc);
+ return RTOnceSlow(pOnce, pfnOnce, NULL, pvUser);
+}
/**
+ * Execute pfnOnce once and register a termination clean-up callback.
+ *
* Serializes execution of the pfnOnce function, making sure it's
* executed exactly once and that nobody returns from RTOnce before
* it has executed successfully.
@@ -131,19 +174,20 @@ RTDECL(int) RTOnceSlow(PRTONCE pOnce, PFNRTONCE pfnOnce, void *pvUser1, void *pv
*
* @param pOnce Pointer to the execute once variable.
* @param pfnOnce The function to executed once.
- * @param pvUser1 The first user parameter for pfnOnce.
- * @param pvUser2 The second user parameter for pfnOnce.
+ * @param pfnCleanUp The function that will be doing the cleaning up.
+ * @param pvUser The user parameter for pfnOnce.
*/
-DECLINLINE(int) RTOnce(PRTONCE pOnce, PFNRTONCE pfnOnce, void *pvUser1, void *pvUser2)
+DECLINLINE(int) RTOnceEx(PRTONCE pOnce, PFNRTONCE pfnOnce, PFNRTONCECLEANUP pfnCleanUp, void *pvUser)
{
int32_t iState = ASMAtomicUoReadS32(&pOnce->iState);
if (RT_LIKELY( iState == RTONCESTATE_DONE
|| iState == RTONCESTATE_DONE_CREATING_SEM
|| iState == RTONCESTATE_DONE_HAVE_SEM ))
return ASMAtomicUoReadS32(&pOnce->rc);
- return RTOnceSlow(pOnce, pfnOnce, pvUser1, pvUser2);
+ return RTOnceSlow(pOnce, pfnOnce, pfnCleanUp, pvUser);
}
+
/**
* Resets an execute once variable.
*
diff --git a/include/iprt/param.h b/include/iprt/param.h
index 0e95e52d..5e80074a 100644
--- a/include/iprt/param.h
+++ b/include/iprt/param.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/path.h b/include/iprt/path.h
index 7e51f87d..7067a1b0 100644
--- a/include/iprt/path.h
+++ b/include/iprt/path.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -49,16 +49,92 @@ RT_C_DECLS_BEGIN
# define RTPATH_MAX (4096 + 4) /* (PATH_MAX + 1) on linux w/ some alignment */
#endif
+/** @def RTPATH_TAG
+ * The default allocation tag used by the RTPath allocation APIs.
+ *
+ * When not defined before the inclusion of iprt/string.h, this will default to
+ * the pointer to the current file name. The string API will make of use of
+ * this as pointer to a volatile but read-only string.
+ */
+#ifndef RTPATH_TAG
+# define RTPATH_TAG (__FILE__)
+#endif
+
+
+/** @name RTPATH_F_XXX - Generic flags for APIs working on the file system.
+ * @{ */
+/** Last component: Work on the link. */
+#define RTPATH_F_ON_LINK RT_BIT_32(0)
+/** Last component: Follow if link. */
+#define RTPATH_F_FOLLOW_LINK RT_BIT_32(1)
+/** Don't allow symbolic links as part of the path.
+ * @remarks this flag is currently not implemented and will be ignored. */
+#define RTPATH_F_NO_SYMLINKS RT_BIT_32(2)
+/** @} */
+
+/** Validates a flags parameter containing RTPATH_F_*.
+ * @remarks The parameters will be referenced multiple times. */
+#define RTPATH_F_IS_VALID(a_fFlags, a_fIgnore) \
+ ( ((a_fFlags) & ~(uint32_t)((a_fIgnore) | RTPATH_F_NO_SYMLINKS)) == RTPATH_F_ON_LINK \
+ || ((a_fFlags) & ~(uint32_t)((a_fIgnore) | RTPATH_F_NO_SYMLINKS)) == RTPATH_F_FOLLOW_LINK )
+
+
+/** @name RTPATH_STR_F_XXX - Generic flags for APIs working with path strings.
+ * @{
+ */
+/** Host OS path style (default 0 value). */
+#define RTPATH_STR_F_STYLE_HOST UINT32_C(0x00000000)
+/** DOS, OS/2 and Windows path style. */
+#define RTPATH_STR_F_STYLE_DOS UINT32_C(0x00000001)
+/** Unix path style. */
+#define RTPATH_STR_F_STYLE_UNIX UINT32_C(0x00000002)
+/** Reserved path style. */
+#define RTPATH_STR_F_STYLE_RESERVED UINT32_C(0x00000003)
+/** The path style mask. */
+#define RTPATH_STR_F_STYLE_MASK UINT32_C(0x00000003)
+/** Partial path - no start.
+ * This causes the API to skip the root specification parsing. */
+#define RTPATH_STR_F_NO_START UINT32_C(0x00000010)
+/** Partial path - no end.
+ * This causes the API to skip the filename and dir-slash parsing. */
+#define RTPATH_STR_F_NO_END UINT32_C(0x00000020)
+/** Partial path - no start and no end. */
+#define RTPATH_STR_F_MIDDLE (RTPATH_STR_F_NO_START | RTPATH_STR_F_NO_END)
+
+/** Reserved for future use. */
+#define RTPATH_STR_F_RESERVED_MASK UINT32_C(0x0000ffcc)
+/** @} */
+
+/** Validates a flags parameter containing RTPATH_FSTR_.
+ * @remarks The parameters will be references multiple times. */
+#define RTPATH_STR_F_IS_VALID(a_fFlags, a_fIgnore) \
+ ( ((a_fFlags) & ~((uint32_t)(a_fIgnore) | RTPATH_STR_F_STYLE_MASK | RTPATH_STR_F_MIDDLE)) == 0 \
+ && ((a_fFlags) & RTPATH_STR_F_STYLE_MASK) != RTPATH_STR_F_STYLE_RESERVED \
+ && ((a_fFlags) & RTPATH_STR_F_RESERVED_MASK) == 0 )
+
+
+/** @def RTPATH_STYLE
+ * The host path style. This is set to RTPATH_STR_F_STYLE_DOS,
+ * RTPATH_STR_F_STYLE_UNIX, or other future styles. */
+#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
+# define RTPATH_STYLE RTPATH_STR_F_STYLE_DOS
+#else
+# define RTPATH_STYLE RTPATH_STR_F_STYLE_UNIX
+#endif
+
+
/** @def RTPATH_SLASH
* The preferred slash character.
*
* @remark IPRT will always accept unix slashes. So, normally you would
* never have to use this define.
*/
-#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
+#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
# define RTPATH_SLASH '\\'
-#else
+#elif RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX
# define RTPATH_SLASH '/'
+#else
+# error "Unsupported RTPATH_STYLE value."
#endif
/** @deprecated Use '/'! */
@@ -72,10 +148,12 @@ RT_C_DECLS_BEGIN
* @remark IPRT will always accept unix slashes. So, normally you would
* never have to use this define.
*/
-#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
+#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
# define RTPATH_SLASH_STR "\\"
-#else
+#elif RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX
# define RTPATH_SLASH_STR "/"
+#else
+# error "Unsupported RTPATH_STYLE value."
#endif
@@ -83,12 +161,14 @@ RT_C_DECLS_BEGIN
* Checks if a character is a slash.
*
* @returns true if it's a slash and false if not.
- * @returns @param ch Char to check.
+ * @returns @param a_ch Char to check.
*/
-#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
-# define RTPATH_IS_SLASH(ch) ( (ch) == '\\' || (ch) == '/' )
+#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
+# define RTPATH_IS_SLASH(a_ch) ( (a_ch) == '\\' || (a_ch) == '/' )
+#elif RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX
+# define RTPATH_IS_SLASH(a_ch) ( (a_ch) == '/' )
#else
-# define RTPATH_IS_SLASH(ch) ( (ch) == '/' )
+# error "Unsupported RTPATH_STYLE value."
#endif
@@ -101,12 +181,14 @@ RT_C_DECLS_BEGIN
* Use the RTPath@<too be created@>() instead.
*
* @returns true if it is and false if it isn't.
- * @returns @param ch Char to check.
+ * @returns @param a_ch Char to check.
*/
-#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
-# define RTPATH_IS_VOLSEP(ch) ( (ch) == ':' )
+#if RTPATH_STYLE == RTPATH_STR_F_STYLE_DOS
+# define RTPATH_IS_VOLSEP(a_ch) ( (a_ch) == ':' )
+#elif RTPATH_STYLE == RTPATH_STR_F_STYLE_UNIX
+# define RTPATH_IS_VOLSEP(a_ch) (false)
#else
-# define RTPATH_IS_VOLSEP(ch) (false)
+# error "Unsupported RTPATH_STYLE value."
#endif
@@ -114,29 +196,10 @@ RT_C_DECLS_BEGIN
* Checks if a character is path component separator
*
* @returns true if it is and false if it isn't.
- * @returns @param ch Char to check.
+ * @returns @param a_ch Char to check.
* @
*/
-#define RTPATH_IS_SEP(ch) ( RTPATH_IS_SLASH(ch) || RTPATH_IS_VOLSEP(ch) )
-
-
-/** @name Generic RTPath flags
- * @{ */
-/** Last component: Work on the link. */
-#define RTPATH_F_ON_LINK RT_BIT_32(0)
-/** Last component: Follow if link. */
-#define RTPATH_F_FOLLOW_LINK RT_BIT_32(1)
-/** Don't allow symbolic links as part of the path.
- * @remarks this flag is currently not implemented and will be ignored. */
-#define RTPATH_F_NO_SYMLINKS RT_BIT_32(2)
-/** @} */
-
-
-/** Validates a flags parameter containing RTPATH_F_*.
- * @remarks The parameters will be referenced multiple times. */
-#define RTPATH_F_IS_VALID(fFlags, fIgnore) \
- ( ((fFlags) & ~(uint32_t)((fIgnore)|RTPATH_F_NO_SYMLINKS)) == RTPATH_F_ON_LINK \
- || ((fFlags) & ~(uint32_t)((fIgnore)|RTPATH_F_NO_SYMLINKS)) == RTPATH_F_FOLLOW_LINK )
+#define RTPATH_IS_SEP(a_ch) ( RTPATH_IS_SLASH(a_ch) || RTPATH_IS_VOLSEP(a_ch) )
/**
@@ -293,7 +356,7 @@ RTDECL(char *) RTPathChangeToDosSlashes(char *pszPath, bool fForce);
RTDECL(char *) RTPathChangeToUnixSlashes(char *pszPath, bool fForce);
/**
- * Parses a path.
+ * Simple parsing of the a path.
*
* It figures the length of the directory component, the offset of
* the file name and the location of the suffix dot.
@@ -310,7 +373,7 @@ RTDECL(char *) RTPathChangeToUnixSlashes(char *pszPath, bool fForce);
* If empty string or if it's ending with a slash this
* will be set to -1. Optional.
*/
-RTDECL(size_t) RTPathParse(const char *pszPath, size_t *pcchDir, ssize_t *poffName, ssize_t *poffSuff);
+RTDECL(size_t) RTPathParseSimple(const char *pszPath, size_t *pcchDir, ssize_t *poffName, ssize_t *poffSuff);
/**
* Finds the filename in a path.
@@ -322,6 +385,17 @@ RTDECL(size_t) RTPathParse(const char *pszPath, size_t *pcchDir, ssize_t *poffNa
RTDECL(char *) RTPathFilename(const char *pszPath);
/**
+ * Finds the filename in a path, extended version.
+ *
+ * @returns Pointer to filename within pszPath.
+ * @returns NULL if no filename (i.e. empty string or ends with a slash).
+ * @param pszPath Path to find filename in.
+ * @param fFlags RTPATH_STR_F_STYLE_XXX. Other RTPATH_STR_F_XXX flags
+ * will be ignored.
+ */
+RTDECL(char *) RTPathFilenameEx(const char *pszPath, uint32_t fFlags);
+
+/**
* Finds the extension part of in a path.
*
* @returns Pointer to extension within pszPath.
@@ -388,6 +462,329 @@ RTDECL(size_t) RTPathCountComponents(const char *pszPath);
*/
RTDECL(int) RTPathCopyComponents(char *pszDst, size_t cbDst, const char *pszSrc, size_t cComponents);
+/** @name Path properties returned by RTPathParse and RTPathSplit.
+ * @{ */
+
+/** Indicates that there is a filename.
+ * If not set, either a lone root spec was given (RTPATH_PROP_UNC,
+ * RTPATH_PROP_ROOT_SLASH, or RTPATH_PROP_VOLUME) or the final component had a
+ * trailing slash (RTPATH_PROP_DIR_SLASH). */
+#define RTPATH_PROP_FILENAME UINT16_C(0x0001)
+/** Indicates that a directory was specified using a trailing slash.
+ * @note This is not set for lone root specifications (RTPATH_PROP_UNC,
+ * RTPATH_PROP_ROOT_SLASH, or RTPATH_PROP_VOLUME).
+ * @note The slash is not counted into the last component. However, it is
+ * counted into cchPath. */
+#define RTPATH_PROP_DIR_SLASH UINT16_C(0x0002)
+
+/** The filename has a suffix (extension). */
+#define RTPATH_PROP_SUFFIX UINT16_C(0x0004)
+/** Indicates that this is an UNC path (Windows and OS/2 only).
+ *
+ * UNC = Universal Naming Convention. It is on the form '//Computer/',
+ * '//Namespace/', '//ComputerName/Resource' and '//Namespace/Resource'.
+ * RTPathParse, RTPathSplit and friends does not consider the 'Resource' as
+ * part of the UNC root specifier. Thus the root specs for the above examples
+ * would be '//ComputerName/' or '//Namespace/'.
+ *
+ * Please note that '//something' is not a UNC path, there must be a slash
+ * following the computer or namespace.
+ */
+#define RTPATH_PROP_UNC UINT16_C(0x0010)
+/** A root slash was specified (unix style root).
+ * (While the path must relative if not set, this being set doesn't make it
+ * absolute.)
+ *
+ * This will be set in the following examples: '/', '/bin', 'C:/', 'C:/Windows',
+ * '//./', '//./PhysicalDisk0', '//example.org/', and '//example.org/share'.
+ *
+ * It will not be set for the following examples: '.', 'bin/ls', 'C:', and
+ * 'C:Windows'.
+ */
+#define RTPATH_PROP_ROOT_SLASH UINT16_C(0x0020)
+/** A volume is specified (Windows, DOS and OS/2).
+ * For examples: 'C:', 'C:/', and 'A:/AutoExec.bat'. */
+#define RTPATH_PROP_VOLUME UINT16_C(0x0040)
+/** The path is absolute, i.e. has a root specifier (root-slash,
+ * volume or UNC) and contains no winding '..' bits, though it may contain
+ * unnecessary slashes (RTPATH_PROP_EXTRA_SLASHES) and '.' components
+ * (RTPATH_PROP_DOT_REFS).
+ *
+ * On systems without volumes and UNC (unix style) it will be set for '/',
+ * '/bin/ls', and '/bin//./ls', but not for 'bin/ls', /bin/../usr/bin/env',
+ * '/./bin/ls' or '/.'.
+ *
+ * On systems with volumes, it will be set for 'C:/', C:/Windows', and
+ * 'C:/./Windows//', but not for 'C:', 'C:Windows', or 'C:/Windows/../boot.ini'.
+ *
+ * On systems with UNC paths, it will be set for '//localhost/',
+ * '//localhost/C$', '//localhost/C$/Windows/System32', '//localhost/.', and
+ * '//localhost/C$//./AutoExec.bat', but not for
+ * '//localhost/C$/Windows/../AutoExec.bat'.
+ *
+ * @note For the RTPathAbs definition, this flag needs to be set while both
+ * RTPATH_PROP_EXTRA_SLASHES and RTPATH_PROP_DOT_REFS must be cleared.
+ */
+#define RTPATH_PROP_ABSOLUTE UINT16_C(0x0100)
+/** Relative path. Inverse of RTPATH_PROP_ABSOLUTE. */
+#define RTPATH_PROP_RELATIVE UINT16_C(0x0200)
+/** The path contains unnecessary slashes. Meaning, that if */
+#define RTPATH_PROP_EXTRA_SLASHES UINT16_C(0x0400)
+/** The path contains references to the special '.' (dot) directory link. */
+#define RTPATH_PROP_DOT_REFS UINT16_C(0x0800)
+/** The path contains references to the special '..' (dot) directory link.
+ * RTPATH_PROP_RELATIVE will always be set together with this. */
+#define RTPATH_PROP_DOTDOT_REFS UINT16_C(0x1000)
+
+
+/** Macro to determin whether to insert a slash after the first component when
+ * joining it with something else.
+ * (All other components in a split or parsed path requies slashes added.) */
+#define RTPATH_PROP_FIRST_NEEDS_NO_SLASH(a_fProps) \
+ RT_BOOL( (a_fProps) & (RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_VOLUME | RTPATH_PROP_UNC) )
+
+/** Macro to determin whether there is a root specification of any kind
+ * (unix, volumes, unc). */
+#define RTPATH_PROP_HAS_ROOT_SPEC(a_fProps) \
+ RT_BOOL( (a_fProps) & (RTPATH_PROP_ROOT_SLASH | RTPATH_PROP_VOLUME | RTPATH_PROP_UNC) )
+
+/** @} */
+
+
+/**
+ * Parsed path.
+ *
+ * The first component is the root, volume or UNC specifier, if present. Use
+ * RTPATH_PROP_HAS_ROOT_SPEC() on RTPATHPARSED::fProps to determine its
+ * precense.
+ *
+ * Other than the root component, no component will include directory separators
+ * (slashes).
+ */
+typedef struct RTPATHPARSED
+{
+ /** Number of path components.
+ * This will always be set on VERR_BUFFER_OVERFLOW returns from RTPathParsed
+ * so the caller can calculate the required buffer size. */
+ uint16_t cComps;
+ /** Path property flags, RTPATH_PROP_XXX */
+ uint16_t fProps;
+ /** On success this is the length of the described path, i.e. sum of all
+ * component lengths and necessary separators.
+ * Do NOT use this to index in the source path in case it contains
+ * unnecessary slashes that RTPathParsed has ignored here. */
+ uint16_t cchPath;
+ /** Reserved for future use. */
+ uint16_t u16Reserved;
+ /** The offset of the filename suffix, offset of the NUL char if none. */
+ uint16_t offSuffix;
+ /** The lenght of the suffix. */
+ uint16_t cchSuffix;
+ /** Array of component descriptors (variable size).
+ * @note Don't try figure the end of the input path by adding up off and cch
+ * of the last component. If RTPATH_PROP_DIR_SLASH is set, there may
+ * be one or more trailing slashes that are unaccounted for! */
+ struct
+ {
+ /** The offset of the component. */
+ uint16_t off;
+ /** The length of the component. */
+ uint16_t cch;
+ } aComps[1];
+} RTPATHPARSED;
+/** Pointer to to a parsed path result. */
+typedef RTPATHPARSED *PRTPATHPARSED;
+/** Pointer to to a const parsed path result. */
+typedef RTPATHPARSED *PCRTPATHPARSED;
+
+
+/**
+ * Parses the path.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_INVALID_POINTER if pParsed or pszPath is an invalid pointer.
+ * @retval VERR_INVALID_PARAMETER if cbOutput is less than the RTPATHPARSED
+ * strucuture. No output. (asserted)
+ * @retval VERR_BUFFER_OVERFLOW there are more components in the path than
+ * there is space in aComps. The required amount of space can be
+ * determined from the pParsed->cComps:
+ * @code
+ * RT_OFFSETOF(RTPATHPARSED, aComps[pParsed->cComps])
+ * @endcode
+ * @retval VERR_PATH_ZERO_LENGTH if the path is empty.
+ *
+ * @param pszPath The path to parse.
+ * @param pParsed Where to store the details of the parsed path.
+ * @param cbParsed The size of the buffer. Must be at least the
+ * size of RTPATHPARSED.
+ * @param fFlags Combination of RTPATH_STR_F_XXX flags.
+ * Most users will pass 0.
+ * @sa RTPathSplit, RTPathSplitA.
+ */
+RTDECL(int) RTPathParse(const char *pszPath, PRTPATHPARSED pParsed, size_t cbParsed, uint32_t fFlags);
+
+/**
+ * Reassembles a path parsed by RTPathParse.
+ *
+ * This will be more useful as more APIs manipulating the RTPATHPARSED output
+ * are added.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_BUFFER_OVERFLOW if @a cbDstPath is less than or equal to
+ * RTPATHPARSED::cchPath.
+ *
+ * @param pszSrcPath The source path.
+ * @param pParsed The parser output for @a pszSrcPath.
+ * @param fFlags Combination of RTPATH_STR_F_STYLE_XXX.
+ * Most users will pass 0.
+ * @param pszDstPath Pointer to the buffer where the path is to be
+ * reassembled.
+ * @param cbDstPath The size of the output buffer.
+ */
+RTDECL(int) RTPathParsedReassemble(const char *pszSrcPath, PRTPATHPARSED pParsed, uint32_t fFlags,
+ char *pszDstPath, size_t cbDstPath);
+
+
+/**
+ * Output buffer for RTPathSplit and RTPathSplitA.
+ */
+typedef struct RTPATHSPLIT
+{
+ /** Number of path components.
+ * This will always be set on VERR_BUFFER_OVERFLOW returns from RTPathParsed
+ * so the caller can calculate the required buffer size. */
+ uint16_t cComps;
+ /** Path property flags, RTPATH_PROP_XXX */
+ uint16_t fProps;
+ /** On success this is the length of the described path, i.e. sum of all
+ * component lengths and necessary separators.
+ * Do NOT use this to index in the source path in case it contains
+ * unnecessary slashes that RTPathSplit has ignored here. */
+ uint16_t cchPath;
+ /** Reserved (internal use). */
+ uint16_t u16Reserved;
+ /** The amount of memory used (on success) or required (on
+ * VERR_BUFFER_OVERFLOW) of this structure and it's strings. */
+ uint32_t cbNeeded;
+ /** Pointer to the filename suffix (the dot), if any. Points to the NUL
+ * character of the last component if none or if RTPATH_PROP_DIR_SLASH is
+ * present. */
+ const char *pszSuffix;
+ /** Array of component strings (variable size). */
+ char *apszComps[1];
+} RTPATHSPLIT;
+/** Pointer to a split path buffer. */
+typedef RTPATHSPLIT *PRTPATHSPLIT;
+/** Pointer to a const split path buffer. */
+typedef RTPATHSPLIT const *PCRTPATHSPLIT;
+
+/**
+ * Splits the path into individual component strings, carved from user supplied
+ * the given buffer block.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_INVALID_POINTER if pParsed or pszPath is an invalid pointer.
+ * @retval VERR_INVALID_PARAMETER if cbOutput is less than the RTPATHSPLIT
+ * strucuture. No output. (asserted)
+ * @retval VERR_BUFFER_OVERFLOW there are more components in the path than
+ * there is space in aComps. The required amount of space can be
+ * determined from the pParsed->cComps:
+ * @code
+ * RT_OFFSETOF(RTPATHPARSED, aComps[pParsed->cComps])
+ * @endcode
+ * @retval VERR_PATH_ZERO_LENGTH if the path is empty.
+ * @retval VERR_FILENAME_TOO_LONG if the filename is too long (close to 64 KB).
+ *
+ * @param pszPath The path to parse.
+ * @param pSplit Where to store the details of the parsed path.
+ * @param cbSplit The size of the buffer pointed to by @a pSplit
+ * (variable sized array at the end). Must be at
+ * least the size of RTPATHSPLIT.
+ * @param fFlags Combination of RTPATH_STR_F_XXX flags.
+ * Most users will pass 0.
+ *
+ * @sa RTPathSplitA, RTPathParse.
+ */
+RTDECL(int) RTPathSplit(const char *pszPath, PRTPATHSPLIT pSplit, size_t cbSplit, uint32_t fFlags);
+
+/**
+ * Splits the path into individual component strings, allocating the buffer on
+ * the default thread heap.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_INVALID_POINTER if pParsed or pszPath is an invalid pointer.
+ * @retval VERR_PATH_ZERO_LENGTH if the path is empty.
+ *
+ * @param pszPath The path to parse.
+ * @param ppSplit Where to return the pointer to the output on
+ * success. This must be freed by calling
+ * RTPathSplitFree().
+ * @param fFlags Combination of RTPATH_STR_F_XXX flags.
+ * Most users will pass 0.
+ * @sa RTPathSplitFree, RTPathSplit, RTPathParse.
+ */
+#define RTPathSplitA(pszPath, ppSplit, fFlags) RTPathSplitATag(pszPath, ppSplit, fFlags, RTPATH_TAG)
+
+/**
+ * Splits the path into individual component strings, allocating the buffer on
+ * the default thread heap.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_INVALID_POINTER if pParsed or pszPath is an invalid pointer.
+ * @retval VERR_PATH_ZERO_LENGTH if the path is empty.
+ *
+ * @param pszPath The path to parse.
+ * @param ppSplit Where to return the pointer to the output on
+ * success. This must be freed by calling
+ * RTPathSplitFree().
+ * @param fFlags Combination of RTPATH_STR_F_XXX flags.
+ * Most users will pass 0.
+ * @param pszTag Allocation tag used for statistics and such.
+ * @sa RTPathSplitFree, RTPathSplit, RTPathParse.
+ */
+RTDECL(int) RTPathSplitATag(const char *pszPath, PRTPATHSPLIT *ppSplit, uint32_t fFlags, const char *pszTag);
+
+/**
+ * Frees buffer returned by RTPathSplitA.
+ *
+ * @param pSplit What RTPathSplitA returned.
+ * @sa RTPathSplitA
+ */
+RTDECL(void) RTPathSplitFree(PRTPATHSPLIT pSplit);
+
+/**
+ * Reassembles a path parsed by RTPathSplit.
+ *
+ * This will be more useful as more APIs manipulating the RTPATHSPLIT output are
+ * added.
+ *
+ * @returns IPRT status code.
+ * @retval VERR_BUFFER_OVERFLOW if @a cbDstPath is less than or equal to
+ * RTPATHSPLIT::cchPath.
+ *
+ * @param pParsed The parser output for @a pszSrcPath.
+ * @param fFlags Combination of RTPATH_STR_F_STYLE_XXX.
+ * Most users will pass 0.
+ * @param pszDstPath Pointer to the buffer where the path is to be
+ * reassembled.
+ * @param cbDstPath The size of the output buffer.
+ */
+RTDECL(int) RTPathSplitReassemble(PRTPATHSPLIT pSplit, uint32_t fFlags, char *pszDstPath, size_t cbDstPath);
+
+/**
+ * Checks if the two paths leads to the file system object.
+ *
+ * If the objects exist, we'll query attributes for them. If that's not
+ * conclusive (some OSes) or one of them doesn't exist, we'll use a combination
+ * of RTPathAbs and RTPathCompare to determine the result.
+ *
+ * @returns true, false, or VERR_FILENAME_TOO_LONG.
+ * @param pszPath1 The first path.
+ * @param pszPath2 The seoncd path.
+ */
+RTDECL(int) RTPathIsSame(const char *pszPath1, const char *pszPath2);
+
+
/**
* Compares two paths.
*
@@ -593,6 +990,24 @@ typedef FNRTPATHTRAVERSER *PFNRTPATHTRAVERSER;
RTDECL(int) RTPathTraverseList(const char *pszPathList, char chSep, PFNRTPATHTRAVERSER pfnCallback, void *pvUser1, void *pvUser2);
+/**
+ * Calculate a relative path between the two given paths.
+ *
+ * @returns IPRT status code.
+ * @retval VINF_SUCCESS on success.
+ * @retval VERR_BUFFER_OVERFLOW if the result is too big to fit within
+ * cbPathDst bytes.
+ * @retval VERR_NOT_SUPPORTED if both paths start with different volume specifiers.
+ * @param pszPathDst Where to store the resulting path.
+ * @param cbPathDst The size of the buffer pszPathDst points to,
+ * terminator included.
+ * @param pszPathFrom The path to start from creating the relative path.
+ * @param pszPathTo The path to reach with the created relative path.
+ */
+RTDECL(int) RTPathCalcRelative(char *pszPathDst, size_t cbPathDst,
+ const char *pszPathFrom,
+ const char *pszPathTo);
+
#ifdef IN_RING3
/**
@@ -616,7 +1031,7 @@ RTDECL(int) RTPathUserHome(char *pszPath, size_t cchPath);
/**
* Gets the user documents directory.
*
- * The returned path isn't guarantied to exist.
+ * The returned path isn't guaranteed to exist.
*
* @returns iprt status code.
* @param pszPath Buffer where to store the path.
@@ -932,6 +1347,17 @@ RTR3DECL(int) RTPathRename(const char *pszSrc, const char *pszDst, unsigned fRe
*/
RTR3DECL(int) RTPathUnlink(const char *pszPath, uint32_t fUnlink);
+/**
+ * A /bin/rm tool.
+ *
+ * @returns Program exit code.
+ *
+ * @param cArgs The number of arguments.
+ * @param papszArgs The argument vector. (Note that this may be
+ * reordered, so the memory must be writable.)
+ */
+RTDECL(RTEXITCODE) RTPathRmCmd(unsigned cArgs, char **papszArgs);
+
#endif /* IN_RING3 */
/** @} */
diff --git a/include/iprt/pipe.h b/include/iprt/pipe.h
index 11715c88..ec9f891d 100644
--- a/include/iprt/pipe.h
+++ b/include/iprt/pipe.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-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;
diff --git a/include/iprt/power.h b/include/iprt/power.h
index 7a290734..49942736 100644
--- a/include/iprt/power.h
+++ b/include/iprt/power.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2008 Oracle Corporation
+ * Copyright (C) 2008-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;
diff --git a/include/iprt/process.h b/include/iprt/process.h
index b359e8ad..790470f4 100644
--- a/include/iprt/process.h
+++ b/include/iprt/process.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/include/iprt/queueatomic.h b/include/iprt/queueatomic.h
new file mode 100644
index 00000000..b5de9485
--- /dev/null
+++ b/include/iprt/queueatomic.h
@@ -0,0 +1,123 @@
+/** @file
+ * IPRT - Generic Work Queue with concurrent atomic access.
+ */
+
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef ___iprt_queueatomic_h
+#define ___iprt_queueatomic_h
+
+#include <iprt/types.h>
+#include <iprt/asm.h>
+
+/** @defgroup grp_rt_list RTQueueAtomic - Generic Work Queue
+ * @ingroup grp_rt
+ *
+ * Implementation of a lockless work queue for threaded environments.
+ * @{
+ */
+
+RT_C_DECLS_BEGIN
+
+/**
+ * A work item
+ */
+typedef struct RTQUEUEATOMICITEM
+{
+ /** Pointer to the next work item in the list. */
+ struct RTQUEUEATOMICITEM * volatile pNext;
+} RTQUEUEATOMICITEM;
+/** Pointer to a work item. */
+typedef RTQUEUEATOMICITEM *PRTQUEUEATOMICITEM;
+/** Pointer to a work item pointer. */
+typedef PRTQUEUEATOMICITEM *PPRTQUEUEATOMICITEM;
+
+/**
+ * Work queue.
+ */
+typedef struct RTQUEUEATOMIC
+{
+ /* Head of the work queue. */
+ volatile PRTQUEUEATOMICITEM pHead;
+} RTQUEUEATOMIC;
+/** Pointer to a work queue. */
+typedef RTQUEUEATOMIC *PRTQUEUEATOMIC;
+
+/**
+ * Initialize a work queue.
+ *
+ * @param pWorkQueue Pointer to an unitialised work queue.
+ */
+DECLINLINE(void) RTQueueAtomicInit(PRTQUEUEATOMIC pWorkQueue)
+{
+ ASMAtomicWriteNullPtr(&pWorkQueue->pHead);
+}
+
+/**
+ * Insert a new item into the work queue.
+ *
+ * @param pWorkQueue The work queue to insert into.
+ * @param pItem The item to insert.
+ */
+DECLINLINE(void) RTQueueAtomicInsert(PRTQUEUEATOMIC pWorkQueue, PRTQUEUEATOMICITEM pItem)
+{
+ PRTQUEUEATOMICITEM pNext = ASMAtomicUoReadPtrT(&pWorkQueue->pHead, PRTQUEUEATOMICITEM);
+ PRTQUEUEATOMICITEM pHeadOld;
+ pItem->pNext = pNext;
+ while (!ASMAtomicCmpXchgExPtr(&pWorkQueue->pHead, pItem, pNext, &pHeadOld))
+ {
+ pNext = pHeadOld;
+ Assert(pNext != pItem);
+ pItem->pNext = pNext;
+ ASMNopPause();
+ }
+}
+
+/**
+ * Remove all items from the given work queue and return them in the inserted order.
+ *
+ * @returns Pointer to the first item.
+ * @param pWorkQueue The work queue.
+ */
+DECLINLINE(PRTQUEUEATOMICITEM) RTQueueAtomicRemoveAll(PRTQUEUEATOMIC pWorkQueue)
+{
+ PRTQUEUEATOMICITEM pHead = ASMAtomicXchgPtrT(&pWorkQueue->pHead, NULL, PRTQUEUEATOMICITEM);
+
+ /* Reverse it. */
+ PRTQUEUEATOMICITEM pCur = pHead;
+ pHead = NULL;
+ while (pCur)
+ {
+ PRTQUEUEATOMICITEM pInsert = pCur;
+ pCur = pCur->pNext;
+ pInsert->pNext = pHead;
+ pHead = pInsert;
+ }
+
+ return pHead;
+}
+
+RT_C_DECLS_END
+
+/** @} */
+
+#endif
diff --git a/include/iprt/rand.h b/include/iprt/rand.h
index f9fa5b80..3a58c5dd 100644
--- a/include/iprt/rand.h
+++ b/include/iprt/rand.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/include/iprt/runtime-loader.h b/include/iprt/runtime-loader.h
index 81ba40e6..58d6bc60 100644
--- a/include/iprt/runtime-loader.h
+++ b/include/iprt/runtime-loader.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2008-2010 Oracle Corporation
+ * Copyright (C) 2008-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -115,7 +115,7 @@ static RTLDRSHAREDFUNC g_aSharedFuncs[] =
* The function which does the actual work for RT_RUNTIME_LOADER_FUNCTION,
* serialised for thread safety.
*/
-static DECLCALLBACK(int) rtldrLoadOnce(void *, void *)
+static DECLCALLBACK(int) rtldrLoadOnce(void *)
{
RTLDRMOD hLib;
int rc;
@@ -144,7 +144,7 @@ RTR3DECL(int) RT_RUNTIME_LOADER_FUNCTION(void)
int rc;
LogFlowFunc(("\n"));
- rc = RTOnce(&s_Once, rtldrLoadOnce, NULL, NULL);
+ rc = RTOnce(&s_Once, rtldrLoadOnce, NULL);
LogFlowFunc(("rc = %Rrc\n", rc));
return rc;
diff --git a/include/iprt/runtime.h b/include/iprt/runtime.h
index b70bfd1b..eb1a4ae9 100644
--- a/include/iprt/runtime.h
+++ b/include/iprt/runtime.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/s3.h b/include/iprt/s3.h
index 2c200d5a..3d448b01 100644
--- a/include/iprt/s3.h
+++ b/include/iprt/s3.h
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-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;
diff --git a/include/iprt/semaphore.h b/include/iprt/semaphore.h
index 0eba39c7..23e59dbb 100644
--- a/include/iprt/semaphore.h
+++ b/include/iprt/semaphore.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/include/iprt/sg.h b/include/iprt/sg.h
index d515de8b..d7083bbd 100644
--- a/include/iprt/sg.h
+++ b/include/iprt/sg.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -187,12 +187,12 @@ RTDECL(size_t) RTSgBufCopyToBuf(PRTSGBUF pSgBuf, void *pvBuf, size_t cbCopy);
*
* @returns Number of bytes copied.
* @param pSgBuf The S/G buffer to copy to.
- * @param pvBuf Buffer to copy the data into.
+ * @param pvBuf Buffer to copy the data from.
* @param cbCopy How many bytes to copy.
*
* @note This operation advances the internal buffer pointer of the S/G buffer.
*/
-RTDECL(size_t) RTSgBufCopyFromBuf(PRTSGBUF pSgBuf, void *pvBuf, size_t cbCopy);
+RTDECL(size_t) RTSgBufCopyFromBuf(PRTSGBUF pSgBuf, const void *pvBuf, size_t cbCopy);
/**
* Advances the internal buffer pointer.
@@ -221,6 +221,17 @@ RTDECL(size_t) RTSgBufAdvance(PRTSGBUF pSgBuf, size_t cbAdvance);
RTDECL(size_t) RTSgBufSegArrayCreate(PRTSGBUF pSgBuf, PRTSGSEG paSeg, unsigned *pcSeg, size_t cbData);
/**
+ * Returns whether the given S/G buffer is zeroed out from the current position
+ * upto the number of bytes to check.
+ *
+ * @returns true if the buffer has only zeros
+ * false otherwise.
+ * @param pSgBuf The S/G buffer.
+ * @param cbCheck Number of bytes to check.
+ */
+RTDECL(bool) RTSgBufIsZero(PRTSGBUF pSgBuf, size_t cbCheck);
+
+/**
* Maps the given S/G buffer to a segment array of another type (for example to
* iovec on POSIX or WSABUF on Windows).
*
diff --git a/include/iprt/sha.h b/include/iprt/sha.h
index 046ca813..ea89759b 100644
--- a/include/iprt/sha.h
+++ b/include/iprt/sha.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-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;
@@ -215,7 +215,32 @@ RTDECL(int) RTSha256ToString(uint8_t const pabDigest[RTSHA256_HASH_SIZE], char *
*/
RTDECL(int) RTSha256FromString(char const *pszDigest, uint8_t pabDigest[RTSHA256_HASH_SIZE]);
+/**
+ * Creates a SHA256 digest for the given memory buffer.
+ *
+ * @returns iprt status code.
+ *
+ * @param pvBuf Memory buffer to create a
+ * SHA256 digest for.
+ * @param cbBuf The amount of data (in bytes).
+ * @param ppszDigest On success the SHA256 digest.
+ * @param pfnProgressCallback optional callback for the progress indication
+ * @param pvUser user defined pointer for the callback
+ */
+RTR3DECL(int) RTSha256Digest(void* pvBuf, size_t cbBuf, char **ppszDigest, PFNRTPROGRESS pfnProgressCallback, void *pvUser);
+/**
+ * Creates a SHA256 digest for the given file.
+ *
+ * @returns iprt status code.
+ *
+ * @param pszFile Filename to create a SHA256
+ * digest for.
+ * @param ppszDigest On success the SHA256 digest.
+ * @param pfnProgressCallback optional callback for the progress indication
+ * @param pvUser user defined pointer for the callback
+ */
+RTR3DECL(int) RTSha256DigestFromFile(const char *pszFile, char **ppszDigest, PFNRTPROGRESS pfnProgressCallback, void *pvUser);
/** The size of a SHA-512 hash. */
#define RTSHA512_HASH_SIZE 64
diff --git a/include/iprt/sort.h b/include/iprt/sort.h
index dd4e93e5..b9f9e1fb 100644
--- a/include/iprt/sort.h
+++ b/include/iprt/sort.h
@@ -3,7 +3,7 @@
*/
/*
- * 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;
diff --git a/include/iprt/spinlock.h b/include/iprt/spinlock.h
index 2c36a0fd..1ca3dfc0 100644
--- a/include/iprt/spinlock.h
+++ b/include/iprt/spinlock.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -73,7 +73,6 @@ RTDECL(int) RTSpinlockDestroy(RTSPINLOCK Spinlock);
* Acquires the spinlock.
*
* @param Spinlock The spinlock to acquire.
- * @param pTmp Where to save the state.
*/
RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock);
@@ -81,7 +80,6 @@ RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock);
* Releases the spinlock.
*
* @param Spinlock The spinlock to acquire.
- * @param pTmp The state to restore. (This better be the same as for the RTSpinlockAcquire() call!)
*/
RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock);
diff --git a/include/iprt/stdint.h b/include/iprt/stdint.h
index 59c2d726..ae94d668 100644
--- a/include/iprt/stdint.h
+++ b/include/iprt/stdint.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-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;
@@ -87,12 +87,12 @@
# undef IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
# ifdef __IBMCPP__
# if __IBMCPP__ < 350 && (defined(__WINDOWS__) || defined(_AIX) || defined(__OS2__))
-# defined IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
+# define IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
# endif
# endif
# ifdef __IBMC__
# if __IBMC__ < 350 && (defined(__WINDOWS__) || defined(_AIX) || defined(__OS2__))
-# defined IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
+# define IPRT_STDINT_USE_STRUCT_FOR_64_BIT_TYPES
# endif
# endif
diff --git a/include/iprt/strcache.h b/include/iprt/strcache.h
index d3883483..65cfd484 100644
--- a/include/iprt/strcache.h
+++ b/include/iprt/strcache.h
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-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;
@@ -87,6 +87,35 @@ RTDECL(const char *) RTStrCacheEnter(RTSTRCACHE hStrCache, const char *psz);
/**
+ * Enters a string into the cache in lower cased form.
+ *
+ * @returns Pointer to a read-only lower cased copy of the string.
+ *
+ * @param hStrCache Handle to the string cache.
+ * @param pchString Pointer to a string. This does not need to be
+ * zero terminated, but must not contain any zero
+ * characters.
+ * @param cchString The number of characters (bytes) to enter.
+ *
+ * @remarks It is implementation dependent whether the returned string pointer
+ * differs when entering the same string twice.
+ */
+RTDECL(const char *) RTStrCacheEnterLowerN(RTSTRCACHE hStrCache, const char *pchString, size_t cchString);
+
+/**
+ * Enters a string into the cache in lower cased form.
+ *
+ * @returns Pointer to a read-only lower cased copy of the string.
+ *
+ * @param hStrCache Handle to the string cache.
+ * @param psz Pointer to a zero terminated string.
+ *
+ * @remarks See RTStrCacheEnterN.
+ */
+RTDECL(const char *) RTStrCacheEnterLower(RTSTRCACHE hStrCache, const char *psz);
+
+
+/**
* Retains a reference to a string.
*
* @returns The new reference count. UINT32_MAX is returned if the string
@@ -100,8 +129,7 @@ RTDECL(uint32_t) RTStrCacheRetain(const char *psz);
* @returns The new reference count.
* UINT32_MAX is returned if the string pointer is invalid.
*
- * @param hStrCache Handle to the string cache. Passing NIL is ok,
- * but this may come a performance hit.
+ * @param hStrCache Handle to the string cache. NIL is NOT allowed.
* @param psz Pointer to a cached string.
*/
RTDECL(uint32_t) RTStrCacheRelease(RTSTRCACHE hStrCache, const char *psz);
@@ -115,6 +143,45 @@ RTDECL(uint32_t) RTStrCacheRelease(RTSTRCACHE hStrCache, const char *psz);
*/
RTDECL(size_t) RTStrCacheLength(const char *psz);
+
+/**
+ * Gets cache statistics.
+ *
+ * All parameters, except @a hStrCache, are optional and can be NULL.
+ *
+ * @returns Number of strings, UINT32_MAX on failure (or not supported).
+ * @param hStrCache Handle to the string cache.
+ * @param pcbStrings The number of string bytes (including
+ * terminators) .
+ * @param pcbChunks Amount of memory we've allocated for the
+ * internal allocator.
+ * @param pcbBigEntries Amount of memory we've allocated off the heap
+ * for really long strings that doesn't fit in the
+ * internal allocator.
+ * @param pcHashCollisions Number of hash table insert collisions.
+ * @param pcHashCollisions2 Number of hash table secondary insert
+ * collisions.
+ * @param pcHashInserts Number of hash table inserts.
+ * @param pcRehashes The number of rehashes.
+ *
+ * @remarks This is not a stable interface as it needs to reflect the cache
+ * implementation.
+ */
+RTDECL(uint32_t) RTStrCacheGetStats(RTSTRCACHE hStrCache, size_t *pcbStrings, size_t *pcbChunks, size_t *pcbBigEntries,
+ uint32_t *pcHashCollisions, uint32_t *pcHashCollisions2, uint32_t *pcHashInserts,
+ uint32_t *pcRehashes);
+
+/**
+ * Indicates whether this a real string cache or a cheap place holder.
+ *
+ * A real string cache will return the same address when a string is added
+ * multiple times.
+ *
+ * @returns true / false.
+ */
+RTDECL(bool) RTStrCacheIsRealImpl(void);
+
+
RT_C_DECLS_END
#endif
diff --git a/include/iprt/stream.h b/include/iprt/stream.h
index e8ac0d08..720d6d84 100644
--- a/include/iprt/stream.h
+++ b/include/iprt/stream.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/include/iprt/string.h b/include/iprt/string.h
index 1f52c75d..fdc44fa6 100644
--- a/include/iprt/string.h
+++ b/include/iprt/string.h
@@ -166,7 +166,7 @@ RT_C_DECLS_BEGIN
#define RTSTR_MAX (~(size_t)0)
-/** @def RTMEM_TAG
+/** @def RTSTR_TAG
* The default allocation tag used by the RTStr allocation APIs.
*
* When not defined before the inclusion of iprt/string.h, this will default to
@@ -2412,6 +2412,31 @@ RTDECL(char *) RTStrToLower(char *psz);
RTDECL(char *) RTStrToUpper(char *psz);
/**
+ * Checks if the string is case foldable, i.e. whether it would change if
+ * subject to RTStrToLower or RTStrToUpper.
+ *
+ * @returns true / false
+ * @param psz The string in question.
+ */
+RTDECL(bool) RTStrIsCaseFoldable(const char *psz);
+
+/**
+ * Checks if the string is upper cased (no lower case chars in it).
+ *
+ * @returns true / false
+ * @param psz The string in question.
+ */
+RTDECL(bool) RTStrIsUpperCased(const char *psz);
+
+/**
+ * Checks if the string is lower cased (no upper case chars in it).
+ *
+ * @returns true / false
+ * @param psz The string in question.
+ */
+RTDECL(bool) RTStrIsLowerCased(const char *psz);
+
+/**
* Find the length of a zero-terminated byte string, given
* a max string length.
*
diff --git a/include/iprt/symlink.h b/include/iprt/symlink.h
index 85edf1ad..2d1e618f 100644
--- a/include/iprt/symlink.h
+++ b/include/iprt/symlink.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-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;
diff --git a/include/iprt/system.h b/include/iprt/system.h
index e7083e27..a86c937a 100644
--- a/include/iprt/system.h
+++ b/include/iprt/system.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -199,7 +199,7 @@ RTDECL(int) RTSystemQueryDmiString(RTSYSDMISTR enmString, char *pszBuf, size_t c
/** Reboot the system after shutdown. */
#define RTSYSTEM_SHUTDOWN_REBOOT UINT32_C(0)
/** Reboot the system after shutdown.
- * The call may return VINF_SYS_MAY_POWER_OFF if the OS /
+ * The call may return VINF_SYS_MAY_POWER_OFF if the OS /
* hardware combination may power off instead of halting. */
#define RTSYSTEM_SHUTDOWN_HALT UINT32_C(1)
/** Power off the system after shutdown.
@@ -229,10 +229,10 @@ RTDECL(int) RTSystemQueryDmiString(RTSYSDMISTR enmString, char *pszBuf, size_t c
* @returns IPRT status code on failure, on success it may or may not return
* depending on the OS.
* @retval VINF_SUCCESS
- * @retval VINF_SYS_MAY_POWER_OFF
- * @retval VERR_SYS_SHUTDOWN_FAILED
- * @retval VERR_SYS_CANNOT_POWER_OFF
- *
+ * @retval VINF_SYS_MAY_POWER_OFF
+ * @retval VERR_SYS_SHUTDOWN_FAILED
+ * @retval VERR_SYS_CANNOT_POWER_OFF
+ *
* @param cMsDelay The delay before the actual reboot. If this is
* not supported by the OS, an immediate reboot
* will be performed.
diff --git a/include/iprt/table.h b/include/iprt/table.h
index 70023979..6746b963 100644
--- a/include/iprt/table.h
+++ b/include/iprt/table.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/tar.h b/include/iprt/tar.h
index 96fad7a6..0b85af37 100644
--- a/include/iprt/tar.h
+++ b/include/iprt/tar.h
@@ -51,6 +51,10 @@ typedef RTTARFILE *PRTTARFILE;
/** Nil RTTARFILE interface handle. */
#define NIL_RTTARFILE ((RTTARFILE)0)
+/** Maximum length of a tar filename, excluding the terminating '\0'. More
+ * does not fit into a tar record. */
+#define RTTAR_NAME_MAX 99
+
/**
* Opens a Tar archive.
*
diff --git a/include/iprt/tcp.h b/include/iprt/tcp.h
index 32d7de45..0e6a4e94 100644
--- a/include/iprt/tcp.h
+++ b/include/iprt/tcp.h
@@ -170,6 +170,40 @@ RTR3DECL(int) RTTcpServerShutdown(PRTTCPSERVER pServer);
*/
RTR3DECL(int) RTTcpClientConnect(const char *pszAddress, uint32_t uPort, PRTSOCKET pSock);
+/** Opaque pointer used by RTTcpClientConnectEx and RTTcpClientCancelConnect. */
+typedef struct RTTCPCLIENTCONNECTCANCEL *PRTTCPCLIENTCONNECTCANCEL;
+
+/**
+ * Connect (as a client) to a TCP Server, extended version.
+ *
+ * @returns iprt status code.
+ * @param pszAddress The address to connect to.
+ * @param uPort The port to connect to.
+ * @param pSock Where to store the handle to the established connection.
+ * @param ppCancelCookie Where to store information for canceling the
+ * operation (from a different thread). Optional.
+ *
+ * The pointer _must_ be initialized to NULL before a
+ * series of connection attempts begins, i.e. at a time
+ * where there will be no RTTcpClientCancelConnect
+ * calls racing access. RTTcpClientCancelConnect will
+ * set it to a special non-NULL value that causes the
+ * current or/and next connect call to fail.
+ *
+ * @sa RTTcpClientCancelConnect
+ */
+RTR3DECL(int) RTTcpClientConnectEx(const char *pszAddress, uint32_t uPort, PRTSOCKET pSock,
+ PRTTCPCLIENTCONNECTCANCEL volatile *ppCancelCookie);
+
+/**
+ * Cancels a RTTcpClientConnectEx call on a different thread.
+ *
+ * @returns iprt status code.
+ * @param ppCancelCookie The address of the cookie pointer shared with the
+ * connect call.
+ */
+RTR3DECL(int) RTTcpClientCancelConnect(PRTTCPCLIENTCONNECTCANCEL volatile *ppCancelCookie);
+
/**
* Close a socket returned by RTTcpClientConnect().
*
diff --git a/include/iprt/test.h b/include/iprt/test.h
index c004ab4f..1788531e 100644
--- a/include/iprt/test.h
+++ b/include/iprt/test.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -29,6 +29,7 @@
#include <iprt/cdefs.h>
#include <iprt/types.h>
#include <iprt/stdarg.h>
+#include <iprt/assert.h>
RT_C_DECLS_BEGIN
@@ -38,7 +39,7 @@ RT_C_DECLS_BEGIN
*/
/** A test handle. */
-typedef struct RTTESTINT *RTTEST;
+typedef R3PTRTYPE(struct RTTESTINT *) RTTEST;
/** A pointer to a test handle. */
typedef RTTEST *PRTTEST;
/** A const pointer to a test handle. */
@@ -78,6 +79,65 @@ typedef enum RTTESTLVL
*/
RTR3DECL(int) RTTestCreate(const char *pszTest, PRTTEST phTest);
+/** @name RTTEST_C_XXX - Flags for RTTestCreateEx.
+ * @{ */
+/** Whether to check the IPRT_TEST_XXX variables when constructing the
+ * instance. The following environment variables get checks:
+ *
+ * - IPRT_TEST_MAX_LEVEL: String value indicating which level.
+ * The env. var. is applied if the program specified the default level
+ * (by passing RTTESTLVL_INVALID).
+ *
+ * - IPRT_TEST_PIPE: The native pipe/fifo handle to write XML
+ * results to.
+ * The env. var. is applied if iNativeTestPipe is -1.
+ *
+ * - IPRT_TEST_FILE: Path to file/named-pipe/fifo/whatever to
+ * write XML results to.
+ * The env. var. is applied if the program specified a NULL path, it is
+ * not applied if the program hands us an empty string.
+ *
+ * - IPRT_TEST_OMIT_TOP_TEST: If present, this makes the XML output omit
+ * the top level test element.
+ * The env. var is applied when present.
+ *
+ */
+#define RTTEST_C_USE_ENV RT_BIT(0)
+/** Whether to omit the top test in the XML. */
+#define RTTEST_C_XML_OMIT_TOP_TEST RT_BIT(1)
+/** Whether to delay the top test XML element until testing commences. */
+#define RTTEST_C_XML_DELAY_TOP_TEST RT_BIT(2)
+/** Whether to try install the test instance in the test TLS slot. Setting
+ * this flag is incompatible with using the RTTestIXxxx variant of the API. */
+#define RTTEST_C_NO_TLS RT_BIT(3)
+/** Mask containing the valid bits. */
+#define RTTEST_C_VALID_MASK UINT32_C(0x0000000f)
+/** @} */
+
+
+/**
+ * Creates a test instance.
+ *
+ * @returns IPRT status code.
+ * @param pszTest The test name.
+ * @param pszXmlFile The XML output file/pipe/whatever.
+ * @param fFlags Flags, see RTTEST_C_XXX.
+ * @param enmMaxLevel The max message level. Use RTTESTLVL_INVALID for
+ * the default output level or one from the
+ * environment. If specified, the environment variable
+ * will not be able to override it.
+ * @param iNativeTestPipe Native handle to a test pipe. -1 if not interested.
+ * @param pszXmlFile The XML output file name. If NULL the environment
+ * may be used. To selectively avoid that, pass an
+ * empty string.
+ * @param phTest Where to store the test instance handle.
+ *
+ * @note At the moment, we don't fail if @a pszXmlFile or @a iNativeTestPipe
+ * fails to open. This may change later.
+ */
+RTR3DECL(int) RTTestCreateEx(const char *pszTest, uint32_t fFlags, RTTESTLVL enmMaxLevel,
+ RTHCINTPTR iNativeTestPipe, const char *pszXmlFile, PRTTEST phTest);
+
/**
* Initializes IPRT and creates a test instance.
*
@@ -102,6 +162,21 @@ RTR3DECL(int) RTTestCreate(const char *pszTest, PRTTEST phTest);
RTR3DECL(RTEXITCODE) RTTestInitAndCreate(const char *pszTest, PRTTEST phTest);
/**
+ * Variant of RTTestInitAndCreate that includes IPRT init flags and argument
+ * vectors.
+ *
+ * @returns RTEXITCODE_SUCCESS on success. On failure an error message is
+ * printed and a suitable exit code is return.
+ *
+ * @param cArgs Pointer to the argument count.
+ * @param ppapszArgs Pointer to the argument vector pointer.
+ * @param fRtInit Flags, see RTR3INIT_XXX.
+ * @param pszTest The test name.
+ * @param phTest Where to store the test instance handle.
+ */
+RTR3DECL(RTEXITCODE) RTTestInitExAndCreate(int cArgs, char ***papszArgs, uint32_t fRtInit, const char *pszTest, PRTTEST phTest);
+
+/**
* Destroys a test instance previously created by RTTestCreate.
*
* @returns IPRT status code.
@@ -120,6 +195,18 @@ RTR3DECL(int) RTTestDestroy(RTTEST hTest);
RTR3DECL(int) RTTestSetDefault(RTTEST hNewDefaultTest, PRTTEST phOldTest);
/**
+ * Changes the test case name.
+ *
+ * @returns IRPT status code.
+ * @param hTest The test handle. If NIL_RTTEST we'll use the one
+ * associated with the calling thread.
+ * @param pszName The new test case name. Empty string is not accepted,
+ * nor are strings longer than 127 chars. Keep it short
+ * but descriptive.
+ */
+RTR3DECL(int) RTTestChangeName(RTTEST hTest, const char *pszName);
+
+/**
* Allocate a block of guarded memory.
*
* @returns IPRT status code.
@@ -294,7 +381,7 @@ RTR3DECL(int) RTTestSubV(RTTEST hTest, const char *pszSubTestFmt, va_list va);
/**
* Completes a sub-test.
*
- * @returns Number of chars printed.
+ * @returns Number of chars printed, negative numbers are IPRT error codes.
* @param hTest The test handle. If NIL_RTTEST we'll use the one
* associated with the calling thread.
*/
@@ -306,7 +393,7 @@ RTR3DECL(int) RTTestSubDone(RTTEST hTest);
* This does not conclude the sub-test, it could be used to report the passing
* of a sub-sub-to-the-power-of-N-test.
*
- * @returns IPRT status code.
+ * @returns Number of chars printed, negative numbers are IPRT error codes.
* @param hTest The test handle. If NIL_RTTEST we'll use the one
* associated with the calling thread.
* @param pszFormat The message. No trailing newline.
@@ -320,7 +407,7 @@ RTR3DECL(int) RTTestPassedV(RTTEST hTest, const char *pszFormat, va_list va);
* This does not conclude the sub-test, it could be used to report the passing
* of a sub-sub-to-the-power-of-N-test.
*
- * @returns IPRT status code.
+ * @returns Number of chars printed, negative numbers are IPRT error codes.
* @param hTest The test handle. If NIL_RTTEST we'll use the one
* associated with the calling thread.
* @param pszFormat The message. No trailing newline.
@@ -329,63 +416,86 @@ RTR3DECL(int) RTTestPassedV(RTTEST hTest, const char *pszFormat, va_list va);
RTR3DECL(int) RTTestPassed(RTTEST hTest, const char *pszFormat, ...);
/**
+ * Marks the current test as 'SKIPPED' and optionally displays a message
+ * explaining why.
+ *
+ * @returns Number of chars printed, negative numbers are IPRT error codes.
+ * @param hTest The test handle. If NIL_RTTEST we'll use the one
+ * associated with the calling thread.
+ * @param pszFormat The message. No trailing newline. Can be NULL or empty.
+ * @param ... The arguments.
+ */
+RTR3DECL(int) RTTestSkipped(RTTEST hTest, const char *pszFormat, ...);
+
+/**
+ * Marks the current test as 'SKIPPED' and optionally displays a message
+ * explaining why.
+ *
+ * @returns Number of chars printed, negative numbers are IPRT error codes.
+ * @param hTest The test handle. If NIL_RTTEST we'll use the one
+ * associated with the calling thread.
+ * @param pszFormat The message. No trailing newline. Can be NULL or empty.
+ * @param va The arguments.
+ */
+RTR3DECL(int) RTTestSkippedV(RTTEST hTest, const char *pszFormat, va_list va);
+
+
+/**
* Value units.
+ *
+ * @remarks This is an interface where we have to be binary compatible with both
+ * older versions of this header and other components using the same
+ * contant values.
+ * @remarks When adding a new item:
+ * - Always add at the end of the list - do NOT group it.
+ * - Add it to rtTestUnitName in r3/test.cpp.
+ * - include/VBox/VMMDevTesting.h (VMMDEV_TESTING_UNIT_XXX).
+ * - Add it to g_aszBs2TestUnitNames in
+ * TestSuite/bootsectors/bootsector2-common-routines.mac.
+ *
*/
typedef enum RTTESTUNIT
{
- /** The usual invalid value. */
+ /** The customary invalid zero value. */
RTTESTUNIT_INVALID = 0,
- /** Percentage. */
- RTTESTUNIT_PCT,
- /** Bytes. */
- RTTESTUNIT_BYTES,
- /** Bytes per second. */
- RTTESTUNIT_BYTES_PER_SEC,
- /** Kilobytes. */
- RTTESTUNIT_KILOBYTES,
- /** Kilobytes per second. */
- RTTESTUNIT_KILOBYTES_PER_SEC,
- /** Megabytes. */
- RTTESTUNIT_MEGABYTES,
- /** Megabytes per second. */
- RTTESTUNIT_MEGABYTES_PER_SEC,
- /** Packets. */
- RTTESTUNIT_PACKETS,
- /** Packets per second. */
- RTTESTUNIT_PACKETS_PER_SEC,
- /** Frames. */
- RTTESTUNIT_FRAMES,
- /** Frames per second. */
- RTTESTUNIT_FRAMES_PER_SEC,
- /** Occurrences. */
- RTTESTUNIT_OCCURRENCES,
- /** Occurrences per second. */
- RTTESTUNIT_OCCURRENCES_PER_SEC,
- /** Calls. */
- RTTESTUNIT_CALLS,
- /** Calls per second. */
- RTTESTUNIT_CALLS_PER_SEC,
- /** Round trips. */
- RTTESTUNIT_ROUND_TRIP,
- /** Seconds. */
- RTTESTUNIT_SECS,
- /** Milliseconds. */
- RTTESTUNIT_MS,
- /** Nanoseconds. */
- RTTESTUNIT_NS,
- /** Nanoseconds per call. */
- RTTESTUNIT_NS_PER_CALL,
- /** Nanoseconds per frame. */
- RTTESTUNIT_NS_PER_FRAME,
- /** Nanoseconds per occurrence. */
- RTTESTUNIT_NS_PER_OCCURRENCE,
- /** Nanoseconds per frame. */
- RTTESTUNIT_NS_PER_PACKET,
- /** Nanoseconds per round trip. */
- RTTESTUNIT_NS_PER_ROUND_TRIP,
+
+ RTTESTUNIT_PCT, /**< Percentage (10^-2). */
+ RTTESTUNIT_BYTES, /**< Bytes. */
+ RTTESTUNIT_BYTES_PER_SEC, /**< Bytes per second. */
+ RTTESTUNIT_KILOBYTES, /**< Kilobytes. */
+ RTTESTUNIT_KILOBYTES_PER_SEC, /**< Kilobytes per second. */
+ RTTESTUNIT_MEGABYTES, /**< Megabytes. */
+ RTTESTUNIT_MEGABYTES_PER_SEC, /**< Megabytes per second. */
+ RTTESTUNIT_PACKETS, /**< Packets. */
+ RTTESTUNIT_PACKETS_PER_SEC, /**< Packets per second. */
+ RTTESTUNIT_FRAMES, /**< Frames. */
+ RTTESTUNIT_FRAMES_PER_SEC, /**< Frames per second. */
+ RTTESTUNIT_OCCURRENCES, /**< Occurrences. */
+ RTTESTUNIT_OCCURRENCES_PER_SEC, /**< Occurrences per second. */
+ RTTESTUNIT_CALLS, /**< Calls. */
+ RTTESTUNIT_CALLS_PER_SEC, /**< Calls per second. */
+ RTTESTUNIT_ROUND_TRIP, /**< Round trips. */
+ RTTESTUNIT_SECS, /**< Seconds. */
+ RTTESTUNIT_MS, /**< Milliseconds. */
+ RTTESTUNIT_NS, /**< Nanoseconds. */
+ RTTESTUNIT_NS_PER_CALL, /**< Nanoseconds per call. */
+ RTTESTUNIT_NS_PER_FRAME, /**< Nanoseconds per frame. */
+ RTTESTUNIT_NS_PER_OCCURRENCE, /**< Nanoseconds per occurrence. */
+ RTTESTUNIT_NS_PER_PACKET, /**< Nanoseconds per frame. */
+ RTTESTUNIT_NS_PER_ROUND_TRIP, /**< Nanoseconds per round trip. */
+ RTTESTUNIT_INSTRS, /**< Instructions. */
+ RTTESTUNIT_INSTRS_PER_SEC, /**< Instructions per second. */
+ RTTESTUNIT_NONE, /**< No unit. */
+ RTTESTUNIT_PP1K, /**< Parts per thousand (10^-3). */
+ RTTESTUNIT_PP10K, /**< Parts per ten thousand (10^-4). */
+ RTTESTUNIT_PPM, /**< Parts per million (10^-6). */
+ RTTESTUNIT_PPB, /**< Parts per billion (10^-9). */
+
/** The end of valid units. */
RTTESTUNIT_END
} RTTESTUNIT;
+AssertCompile(RTTESTUNIT_INSTRS == 0x19);
+AssertCompile(RTTESTUNIT_NONE == 0x1b);
/**
* Report a named test result value.
@@ -451,6 +561,15 @@ RTR3DECL(int) RTTestErrorInc(RTTEST hTest);
RTR3DECL(uint32_t) RTTestErrorCount(RTTEST hTest);
/**
+ * Get the error count of the current sub test.
+ *
+ * @returns The error counter, UINT32_MAX if no valid test handle.
+ * @param hTest The test handle. If NIL_RTTEST we'll use the one
+ * associated with the calling thread.
+ */
+RTR3DECL(uint32_t) RTTestSubErrorCount(RTTEST hTest);
+
+/**
* Increments the error counter and prints a failure message.
*
* @returns IPRT status code.
diff --git a/include/iprt/thread.h b/include/iprt/thread.h
index 6bd63b99..35361f80 100644
--- a/include/iprt/thread.h
+++ b/include/iprt/thread.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -533,6 +533,10 @@ typedef struct RTTHREADPREEMPTSTATE
/** Reserved, MBZ. */
uint8_t bReserved3;
# define RTTHREADPREEMPTSTATE_INITIALIZER { NIL_RTCPUID, 255, 0, 0, 0 }
+# elif defined(RT_OS_HAIKU)
+ /** The cpu_state. Don't touch! */
+ uint32_t uOldCpuState;
+# define RTTHREADPREEMPTSTATE_INITIALIZER { NIL_RTCPUID, 0 }
# elif defined(RT_OS_SOLARIS)
/** The Old PIL. Don't touch! */
uint32_t uOldPil;
@@ -575,6 +579,109 @@ RTDECL(void) RTThreadPreemptRestore(PRTTHREADPREEMPTSTATE pState);
*/
RTDECL(bool) RTThreadIsInInterrupt(RTTHREAD hThread);
+
+/**
+ * Thread-context events.
+ */
+typedef enum RTTHREADCTXEVENT
+{
+ /** This thread is about to be preempted. */
+ RTTHREADCTXEVENT_PREEMPTING = 0,
+ /** This thread has just been resumed. */
+ RTTHREADCTXEVENT_RESUMED,
+ /** The usual 32-bit size hack. */
+ RTTHREADCTXEVENT_32BIT_HACK = 0x7fffffff
+} RTTHREADCTXEVENT;
+
+/**
+ * Thread-context hook.
+ *
+ * @returns IPRT status code.
+ * @param enmEvent The thread-context event.
+ * @param pvUser User argument.
+ *
+ * @remarks This function may be called under different contexts, i.e. with
+ * different locks held, with/without preemption disabled depending on
+ * the event in @a enmEvent.
+ */
+typedef DECLCALLBACK(void) FNRTTHREADCTXHOOK(RTTHREADCTXEVENT enmEvent, void *pvUser);
+/** Pointer to a thread-context hook. */
+typedef FNRTTHREADCTXHOOK *PFNRTTHREADCTXHOOK;
+
+/**
+ * Initializes a thread-context hook for the current thread.
+ *
+ * This must be called once per-thread before using RTThreadCtxHooksRegister().
+ *
+ * @returns IPRT status code.
+ * @param phThreadCtx Where to store the thread-context handle.
+ *
+ * @remarks This must be called with preemption enabled!
+ */
+RTDECL(int) RTThreadCtxHooksCreate(PRTTHREADCTX phThreadCtx);
+
+/**
+ * Retains a new reference to a thread-context hook.
+ *
+ * @returns New reference count.
+ * UINT32_MAX is returned if the handle is invalid (asserted).
+ * @param phThreadCtx Pointer to the thread-context handle.
+ *
+ * @remarks This can be called from any thread. Can be called with preemption
+ * disabled.
+ */
+RTDECL(uint32_t) RTThreadCtxHooksRetain(RTTHREADCTX hThreadCtx);
+
+/**
+ * Releases a reference to a thread-context hook.
+ *
+ * @returns New reference count.
+ * @retval 0 if the thread-context hook was freed or @a hThreadCtx is
+ * NIL_RTTHREADCTX.
+ * @retval UINT32_MAX is returned if the handle is invalid (asserted).
+ *
+ * @param hThreadCtx The thread-context handle.
+ *
+ * @remarks This can be called from any thread but must be called with
+ * preemption enabled!
+ */
+RTDECL(uint32_t) RTThreadCtxHooksRelease(RTTHREADCTX hThreadCtx);
+
+/**
+ * Registers a thread-context hook for the current thread to receive
+ * notifications for all supported thread-context events.
+ *
+ * @returns IPRT status code.
+ * @param hThreadCtx The thread-context handle.
+ * @param pfnThreadHook Pointer to a thread-context hook (a callback)
+ * for all thread-context events.
+ * @param pvUser User argument (optional, can be NULL).
+ *
+ * @remarks Can be called with preemption disabled.
+ */
+RTDECL(int) RTThreadCtxHooksRegister(RTTHREADCTX hThreadCtx, PFNRTTHREADCTXHOOK pfnThreadHook, void *pvUser);
+
+/**
+ * Deregisters the thread-context hook for the current thread.
+ *
+ * @returns IPRT status code.
+ * @param hThreadCtx The thread-context handle.
+ *
+ * @remarks Can be called with preemption disabled.
+ */
+RTDECL(int) RTThreadCtxHooksDeregister(RTTHREADCTX hThreadCtx);
+
+/**
+ * Are thread-context hooks registered for the thread?
+ *
+ * @returns true if registered, false if not supported or not registered.
+ * @param hThreadCtx The thread-context handle.
+ *
+ * @remarks Can be called from any thread (but possibility of races when
+ * it's not the current thread!)
+ */
+RTDECL(bool) RTThreadCtxHooksAreRegistered(RTTHREADCTX hThreadCtx);
+
# endif /* IN_RING0 */
diff --git a/include/iprt/time.h b/include/iprt/time.h
index 7a94dcd7..2981d9de 100644
--- a/include/iprt/time.h
+++ b/include/iprt/time.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -524,6 +524,19 @@ DECLINLINE(bool) RTTimeSpecIsEqual(PCRTTIMESPEC pTime1, PCRTTIMESPEC pTime2)
*/
RTDECL(char *) RTTimeSpecToString(PCRTTIMESPEC pTime, char *psz, size_t cb);
+/**
+ * Attempts to convert an ISO date string to a time structure.
+ *
+ * We're a little forgiving with zero padding, unspecified parts, and leading
+ * and trailing spaces.
+ *
+ * @retval pTime on success,
+ * @retval NULL on failure.
+ * @param pTime The time spec.
+ * @param pszString The ISO date string to convert.
+ */
+RTDECL(PRTTIMESPEC) RTTimeSpecFromString(PRTTIMESPEC pTime, const char *pszString);
+
/** @} */
@@ -709,6 +722,19 @@ RTDECL(PRTTIME) RTTimeLocalNormalize(PRTTIME pTime);
RTDECL(char *) RTTimeToString(PCRTTIME pTime, char *psz, size_t cb);
/**
+ * Attempts to convert an ISO date string to a time structure.
+ *
+ * We're a little forgiving with zero padding, unspecified parts, and leading
+ * and trailing spaces.
+ *
+ * @retval pTime on success,
+ * @retval NULL on failure.
+ * @param pTime Where to store the time on success.
+ * @param pszString The ISO date string to convert.
+ */
+RTDECL(PRTTIME) RTTimeFromString(PRTTIME pTime, const char *pszString);
+
+/**
* Checks if a year is a leap year or not.
*
* @returns true if it's a leap year.
diff --git a/include/iprt/types.h b/include/iprt/types.h
index e841dea5..3c88ec22 100644
--- a/include/iprt/types.h
+++ b/include/iprt/types.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2011 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -165,6 +165,8 @@ RT_C_DECLS_END
# include <iprt/nocrt/compiler/compiler.h>
#endif /* no crt */
+
+
/** @def NULL
* NULL pointer.
*/
@@ -194,9 +196,9 @@ RT_C_DECLS_END
#endif
/*
- * C doesn't have bool.
+ * C doesn't have bool, nor does VisualAge for C++ v3.08.
*/
-#ifndef __cplusplus
+#if !defined(__cplusplus) || (defined(__IBMCPP__) && defined(RT_OS_OS2))
# if defined(__GNUC__)
# if defined(RT_OS_LINUX) && __GNUC__ < 3
typedef uint8_t bool;
@@ -205,7 +207,7 @@ typedef uint8_t bool;
typedef _Bool bool;
# endif
# else
-# if defined(RT_OS_DARWIN) && defined(_STDBOOL_H)
+# if (defined(RT_OS_DARWIN) || defined(RT_OS_HAIKU)) && (defined(_STDBOOL_H) || defined(__STDBOOL_H))
# undef bool
# endif
typedef _Bool bool;
@@ -395,6 +397,7 @@ typedef const RTUINT64U *PCRTUINT64U;
/**
* 128-bit unsigned integer union.
*/
+#pragma pack(1)
typedef union RTUINT128U
{
/** Natural view.
@@ -470,6 +473,7 @@ typedef union RTUINT128U
/** 8-bit view. */
uint8_t au8[16];
} RTUINT128U;
+#pragma pack()
/** Pointer to a 64-bit unsigned integer union. */
typedef RTUINT128U *PRTUINT128U;
/** Pointer to a const 64-bit unsigned integer union. */
@@ -546,6 +550,8 @@ typedef RTFLOAT64U *PRTFLOAT64U;
typedef const RTFLOAT64U *PCRTFLOAT64U;
+#if !defined(__IBMCPP__) && !defined(__IBMC__)
+
/**
* Extended Double precision floating point format (80-bit).
*/
@@ -690,6 +696,8 @@ typedef RTFLOAT80U2 *PRTFLOAT80U2;
* variant. */
typedef const RTFLOAT80U2 *PCRTFLOAT80U2;
+#endif /* uint16_t bitfields doesn't work */
+
/** Generic function type.
* @see PFNRT
@@ -733,15 +741,27 @@ typedef const struct RTTIMESPEC *PCRTTIMESPEC;
typedef union RTPTRUNION
{
/** Pointer into the void... */
- void *pv;
+ void *pv;
+ /** Pointer to char value. */
+ char *pch;
+ /** Pointer to char value. */
+ unsigned char *puch;
+ /** Pointer to a int value. */
+ int *pi;
+ /** Pointer to a unsigned int value. */
+ unsigned int *pu;
+ /** Pointer to a long value. */
+ long *pl;
+ /** Pointer to a long value. */
+ unsigned long *pul;
/** Pointer to a 8-bit unsigned value. */
- uint8_t *pu8;
+ uint8_t *pu8;
/** Pointer to a 16-bit unsigned value. */
- uint16_t *pu16;
+ uint16_t *pu16;
/** Pointer to a 32-bit unsigned value. */
- uint32_t *pu32;
+ uint32_t *pu32;
/** Pointer to a 64-bit unsigned value. */
- uint64_t *pu64;
+ uint64_t *pu64;
} RTPTRUNION;
/** Pointer to a pointer union. */
typedef RTPTRUNION *PRTPTRUNION;
@@ -752,15 +772,27 @@ typedef RTPTRUNION *PRTPTRUNION;
typedef union RTCPTRUNION
{
/** Pointer into the void... */
- void const *pv;
+ void const *pv;
+ /** Pointer to char value. */
+ char const *pch;
+ /** Pointer to char value. */
+ unsigned char const *puch;
+ /** Pointer to a int value. */
+ int const *pi;
+ /** Pointer to a unsigned int value. */
+ unsigned int const *pu;
+ /** Pointer to a long value. */
+ long const *pl;
+ /** Pointer to a long value. */
+ unsigned long const *pul;
/** Pointer to a 8-bit unsigned value. */
- uint8_t const *pu8;
+ uint8_t const *pu8;
/** Pointer to a 16-bit unsigned value. */
- uint16_t const *pu16;
+ uint16_t const *pu16;
/** Pointer to a 32-bit unsigned value. */
- uint32_t const *pu32;
+ uint32_t const *pu32;
/** Pointer to a 64-bit unsigned value. */
- uint64_t const *pu64;
+ uint64_t const *pu64;
} RTCPTRUNION;
/** Pointer to a const pointer union. */
typedef RTCPTRUNION *PRTCPTRUNION;
@@ -771,15 +803,27 @@ typedef RTCPTRUNION *PRTCPTRUNION;
typedef union RTVPTRUNION
{
/** Pointer into the void... */
- void volatile *pv;
+ void volatile *pv;
+ /** Pointer to char value. */
+ char volatile *pch;
+ /** Pointer to char value. */
+ unsigned char volatile *puch;
+ /** Pointer to a int value. */
+ int volatile *pi;
+ /** Pointer to a unsigned int value. */
+ unsigned int volatile *pu;
+ /** Pointer to a long value. */
+ long volatile *pl;
+ /** Pointer to a long value. */
+ unsigned long volatile *pul;
/** Pointer to a 8-bit unsigned value. */
- uint8_t volatile *pu8;
+ uint8_t volatile *pu8;
/** Pointer to a 16-bit unsigned value. */
- uint16_t volatile *pu16;
+ uint16_t volatile *pu16;
/** Pointer to a 32-bit unsigned value. */
- uint32_t volatile *pu32;
+ uint32_t volatile *pu32;
/** Pointer to a 64-bit unsigned value. */
- uint64_t volatile *pu64;
+ uint64_t volatile *pu64;
} RTVPTRUNION;
/** Pointer to a const pointer union. */
typedef RTVPTRUNION *PRTVPTRUNION;
@@ -790,15 +834,27 @@ typedef RTVPTRUNION *PRTVPTRUNION;
typedef union RTCVPTRUNION
{
/** Pointer into the void... */
- void const volatile *pv;
+ void const volatile *pv;
+ /** Pointer to char value. */
+ char const volatile *pch;
+ /** Pointer to char value. */
+ unsigned char const volatile *puch;
+ /** Pointer to a int value. */
+ int const volatile *pi;
+ /** Pointer to a unsigned int value. */
+ unsigned int const volatile *pu;
+ /** Pointer to a long value. */
+ long const volatile *pl;
+ /** Pointer to a long value. */
+ unsigned long const volatile *pul;
/** Pointer to a 8-bit unsigned value. */
- uint8_t const volatile *pu8;
+ uint8_t const volatile *pu8;
/** Pointer to a 16-bit unsigned value. */
- uint16_t const volatile *pu16;
+ uint16_t const volatile *pu16;
/** Pointer to a 32-bit unsigned value. */
- uint32_t const volatile *pu32;
+ uint32_t const volatile *pu32;
/** Pointer to a 64-bit unsigned value. */
- uint64_t const volatile *pu64;
+ uint64_t const volatile *pu64;
} RTCVPTRUNION;
/** Pointer to a const pointer union. */
typedef RTCVPTRUNION *PRTCVPTRUNION;
@@ -1585,6 +1641,11 @@ typedef struct RTCRITSECT *PRTCRITSECT;
/** Pointer to a const critical section. */
typedef const struct RTCRITSECT *PCRTCRITSECT;
+/** Pointer to a read/write critical section. */
+typedef struct RTCRITSECTRW *PRTCRITSECTRW;
+/** Pointer to a const read/write critical section. */
+typedef const struct RTCRITSECTRW *PCRTCRITSECTRW;
+
/** Condition variable handle. */
typedef R3PTRTYPE(struct RTCONDVARINTERNAL *) RTCONDVAR;
@@ -1763,6 +1824,13 @@ typedef RTTHREAD *PRTTHREAD;
/** Nil thread handle. */
#define NIL_RTTHREAD 0
+/** Thread-context handle.*/
+typedef R0PTRTYPE(struct RTTHREADCTXINT *) RTTHREADCTX;
+/** Pointer to thread handle. */
+typedef RTTHREADCTX *PRTTHREADCTX;
+/** Nil thread-context handle. */
+#define NIL_RTTHREADCTX 0
+
/** A TLS index. */
typedef RTHCINTPTR RTTLS;
/** Pointer to a TLS index. */
@@ -1952,6 +2020,19 @@ typedef RTVFSSYMLINK *PRTVFSSYMLINK;
/** A NIL VFS symbolic link handle. */
#define NIL_RTVFSSYMLINK ((RTVFSSYMLINK)~(uintptr_t)0)
+/** Async I/O manager handle. */
+typedef struct RTAIOMGRINT *RTAIOMGR;
+/** Pointer to a async I/O manager handle. */
+typedef RTAIOMGR *PRTAIOMGR;
+/** A NIL async I/O manager handle. */
+#define NIL_RTAIOMGR ((RTAIOMGR)~(uintptr_t)0)
+
+/** Async I/O manager file handle. */
+typedef struct RTAIOMGRFILEINT *RTAIOMGRFILE;
+/** Pointer to a async I/O manager file handle. */
+typedef RTAIOMGRFILE *PRTAIOMGRFILE;
+/** A NIL async I/O manager file handle. */
+#define NIL_RTAIOMGRFILE ((RTAIOMGRFILE)~(uintptr_t)0)
/**
* Handle type.
@@ -2111,6 +2192,9 @@ typedef RTUUID *PRTUUID;
/** Pointer to readonly UUID data. */
typedef const RTUUID *PCRTUUID;
+/** Initializes a RTUUID structure with all zeros (RTUuidIsNull() true). */
+#define RTUUID_INITIALIZE_NULL { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
+
/** UUID string maximum length. */
#define RTUUID_STR_LENGTH 37
@@ -2273,6 +2357,9 @@ typedef const RTMAC *PCRTMAC;
/** Pointer to a lock validator record.
* The structure definition is found in iprt/lockvalidator.h. */
typedef struct RTLOCKVALRECEXCL *PRTLOCKVALRECEXCL;
+/** Pointer to a record of one ownership share.
+ * The structure definition is found in iprt/lockvalidator.h. */
+typedef struct RTLOCKVALRECSHRD *PRTLOCKVALRECSHRD;
/** Pointer to a lock validator source poisition.
* The structure definition is found in iprt/lockvalidator.h. */
typedef struct RTLOCKVALSRCPOS *PRTLOCKVALSRCPOS;
diff --git a/include/iprt/uni.h b/include/iprt/uni.h
index 6f0c23ec..a1161db1 100644
--- a/include/iprt/uni.h
+++ b/include/iprt/uni.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
@@ -46,8 +46,8 @@
RT_C_DECLS_BEGIN
-
#ifndef RTUNI_USE_WCTYPE
+
/**
* A unicode flags range.
* @internal
@@ -161,6 +161,20 @@ DECLINLINE(bool) RTUniCpIsLower(RTUNICP CodePoint)
/**
+ * Checks if a unicode code point is case foldable.
+ *
+ * @returns true if it is.
+ * @returns false if it isn't.
+ * @param CodePoint The code point.
+ */
+DECLINLINE(bool) RTUniCpIsFoldable(RTUNICP CodePoint)
+{
+ /* Right enough. */
+ return (rtUniCpFlags(CodePoint) & (RTUNI_LOWER | RTUNI_UPPER)) != 0;
+}
+
+
+/**
* Checks if a unicode code point is alphabetic.
*
* @returns true if it is.
@@ -303,6 +317,20 @@ DECLINLINE(bool) RTUniCpIsLower(RTUNICP CodePoint)
/**
+ * Checks if a unicode code point is case foldable.
+ *
+ * @returns true if it is.
+ * @returns false if it isn't.
+ * @param CodePoint The code point.
+ */
+DECLINLINE(bool) RTUniCpIsFoldable(RTUNICP CodePoint)
+{
+ /* Right enough. */
+ return iswupper(CodePoint) || iswlower(CodePoint);
+}
+
+
+/**
* Checks if a unicode code point is alphabetic.
*
* @returns true if it is.
diff --git a/include/iprt/uuid.h b/include/iprt/uuid.h
index 94604e2b..1a9c9750 100644
--- a/include/iprt/uuid.h
+++ b/include/iprt/uuid.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
diff --git a/include/iprt/vfs.h b/include/iprt/vfs.h
index 6eefa01d..787c1b39 100644
--- a/include/iprt/vfs.h
+++ b/include/iprt/vfs.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -332,7 +332,7 @@ RTDECL(uint32_t) RTVfsDirRelease(RTVFSDIR hVfsDir);
/** @} */
-/** @defgroup grp_vfs_iostream VFS Symbolic Link API
+/** @defgroup grp_vfs_symlink VFS Symbolic Link API
*
* @remarks The TAR VFS and filesystem stream uses symbolic links for
* describing hard links as well. The users must use RTFS_IS_SYMLINK
@@ -452,6 +452,17 @@ RTDECL(int) RTVfsSymlinkRead(RTVFSSYMLINK hVfsSym, char *pszTarget, size
RTDECL(int) RTVfsIoStrmFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos);
/**
+ * Convenience function combining RTFileOpen with RTVfsIoStrmFromRTFile.
+ *
+ * @returns IPRT status code.
+ * @param pszFilename The path to the file in the normal file system.
+ * @param fOpen The flags to pass to RTFileOpen when opening the
+ * file, i.e. RTFILE_O_XXX.
+ * @param phVfsIos Where to return the VFS I/O stream handle.
+ */
+RTDECL(int) RTVfsIoStrmOpenNormal(const char *pszFilename, uint64_t fOpen, PRTVFSIOSTREAM phVfsIos);
+
+/**
* Create a VFS I/O stream handle from one of the standard handles.
*
* @returns IPRT status code.
@@ -594,7 +605,7 @@ RTDECL(int) RTVfsIoStrmSgRead(RTVFSIOSTREAM hVfsIos, PCRTSGBUF pSgBuf, b
* attemted written.
* @param fBlocking Whether the call is blocking (@c true) or not. If
* not, the @a pcbWritten parameter must not be NULL.
- * @param pcbRead Where to always store the number of bytes actually
+ * @param pcbWritten Where to always store the number of bytes actually
* written. This can be NULL if @a fBlocking is true.
* @sa RTFileSgWrite, RTSocketSgWrite
*/
@@ -705,6 +716,17 @@ RTDECL(int) RTVfsFileFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeav
RTDECL(RTHCUINTPTR) RTVfsFileToNative(RTFILE hVfsFile);
/**
+ * Convenience function combining RTFileOpen with RTVfsFileFromRTFile.
+ *
+ * @returns IPRT status code.
+ * @param pszFilename The path to the file in the normal file system.
+ * @param fOpen The flags to pass to RTFileOpen when opening the
+ * file, i.e. RTFILE_O_XXX.
+ * @param phVfsFile Where to return the VFS file handle.
+ */
+RTDECL(int) RTVfsFileOpenNormal(const char *pszFilename, uint64_t fOpen, PRTVFSFILE phVfsFile);
+
+/**
* Convert the VFS file handle to a VFS I/O stream handle.
*
* @returns The VFS I/O stream handle on success, this must be released.
diff --git a/include/iprt/vfslowlevel.h b/include/iprt/vfslowlevel.h
index d5208cf4..c077016e 100644
--- a/include/iprt/vfslowlevel.h
+++ b/include/iprt/vfslowlevel.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2010 Oracle Corporation
+ * Copyright (C) 2010-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
diff --git a/include/iprt/win/lazy-dbghelp.h b/include/iprt/win/lazy-dbghelp.h
new file mode 100644
index 00000000..6232e909
--- /dev/null
+++ b/include/iprt/win/lazy-dbghelp.h
@@ -0,0 +1,137 @@
+/** @file
+ * Symbols from dbghelp.dll, allowing us to select which one to load.
+ */
+
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef ___iprt_win_lazy_dbghelp_h
+#define ___iprt_win_lazy_dbghelp_h
+
+#include <iprt/ldrlazy.h>
+#include <iprt/path.h>
+#include <iprt/env.h>
+
+
+/**
+ * Custom loader callback.
+ * @returns Module handle or NIL_RTLDRMOD.
+ */
+static int rtLdrLazyLoadDbgHelp(const char *pszFile, PRTLDRMOD phMod)
+{
+ static const struct
+ {
+ const char *pszEnv;
+ const char *pszSubDir;
+ } s_aLocations[] =
+ {
+#ifdef RT_ARCH_AMD64
+ { "ProgramFiles(x86)", "Windows Kits\\8.1\\Debuggers\\x64\\dbghelp.dll" },
+ { "ProgramFiles(x86)", "Windows Kits\\8.0\\Debuggers\\x64\\dbghelp.dll" },
+ { "ProgramFiles", "Debugging Tools for Windows (x64)\\dbghelp.dll" },
+#else
+ { "ProgramFiles", "Windows Kits\\8.1\\Debuggers\\x86\\dbghelp.dll" },
+ { "ProgramFiles", "Windows Kits\\8.0\\Debuggers\\x86\\dbghelp.dll" },
+ { "ProgramFiles", "Debugging Tools for Windows (x86)\\dbghelp.dll" },
+#endif /** @todo More places we should look? */
+ };
+ uint32_t i;
+ for (i = 0; i < RT_ELEMENTS(s_aLocations); i++)
+ {
+ char szPath[RTPATH_MAX];
+ size_t cchPath;
+ int rc = RTEnvGetEx(RTENV_DEFAULT, s_aLocations[i].pszEnv, szPath, sizeof(szPath), &cchPath);
+ if (RT_SUCCESS(rc))
+ {
+ rc = RTPathAppend(szPath, sizeof(szPath), s_aLocations[i].pszSubDir);
+ if (RT_SUCCESS(rc))
+ {
+ rc = RTLdrLoad(szPath, phMod);
+ if (RT_SUCCESS(rc))
+ return rc;
+ }
+ }
+ }
+
+ /* Fall back on the system one, if present. */
+ return RTLdrLoadSystem(pszFile, true /*fNoUnload*/, phMod);
+}
+
+RTLDRLAZY_MODULE_EX(dbghelp, "dbghelp.dll", rtLdrLazyLoadDbgHelp);
+
+RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymInitialize, (HANDLE a1, PCWSTR a2, BOOL a3), (a1, a2, a3), FALSE);
+#undef SymInitialize
+#define SymInitialize RTLDRLAZY_FUNC_NAME(dbghelp, SymInitialize)
+
+RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymCleanup, (HANDLE a1), (a1), FALSE);
+#undef SymCleanup
+#define SymCleanup RTLDRLAZY_FUNC_NAME(dbghelp, SymCleanup)
+
+RTLDRLAZY_FUNC(dbghelp, DWORD, WINAPI, SymGetOptions, (VOID), (), 0);
+#undef SymGetOptions
+#define SymGetOptions RTLDRLAZY_FUNC_NAME(dbghelp, SymGetOptions)
+
+RTLDRLAZY_FUNC(dbghelp, DWORD, WINAPI, SymSetOptions, (DWORD a1), (a1), 0);
+#undef SymSetOptions
+#define SymSetOptions RTLDRLAZY_FUNC_NAME(dbghelp, SymSetOptions)
+
+RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymRegisterCallback64, (HANDLE a1, PSYMBOL_REGISTERED_CALLBACK64 a2, ULONG64 a3),
+ (a1, a2, a3), FALSE);
+#undef SymRegisterCallback64
+#define SymRegisterCallback64 RTLDRLAZY_FUNC_NAME(dbghelp, SymRegisterCallback64)
+
+RTLDRLAZY_FUNC(dbghelp, DWORD64, WINAPI, SymLoadModuleEx,
+ (HANDLE a1, HANDLE a2, PCSTR a3, PCSTR a4, DWORD64 a5, DWORD a6, PMODLOAD_DATA a7, DWORD a8),
+ (a1, a2, a3, a4, a5, a6, a7, a8), 0);
+#undef SymLoadModuleEx
+#define SymLoadModuleEx RTLDRLAZY_FUNC_NAME(dbghelp, SymLoadModuleEx)
+
+RTLDRLAZY_FUNC(dbghelp, DWORD64, WINAPI, SymLoadModuleExW,
+ (HANDLE a1, HANDLE a2, PCWSTR a3, PCWSTR a4, DWORD64 a5, DWORD a6, PMODLOAD_DATA a7, DWORD a8),
+ (a1, a2, a3, a4, a5, a6, a7, a8), 0);
+#undef SymLoadModuleExW
+#define SymLoadModuleExW RTLDRLAZY_FUNC_NAME(dbghelp, SymLoadModuleExW)
+
+RTLDRLAZY_FUNC(dbghelp, DWORD64, WINAPI, SymUnloadModule64, (HANDLE a1, DWORD64 a2), (a1, a2), 0);
+#undef SymUnloadModule64
+#define SymUnloadModule64 RTLDRLAZY_FUNC_NAME(dbghelp, SymUnloadModule64)
+
+RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymEnumSymbols,
+ (HANDLE a1, ULONG64 a2, PCSTR a3, PSYM_ENUMERATESYMBOLS_CALLBACK a4, PVOID a5),
+ (a1, a2, a3, a4, a5), FALSE);
+#undef SymEnumSymbols
+#define SymEnumSymbols RTLDRLAZY_FUNC_NAME(dbghelp, SymEnumSymbols)
+
+RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymEnumLinesW,
+ (HANDLE a1, ULONG64 a2, PCWSTR a3, PCWSTR a4, PSYM_ENUMLINES_CALLBACKW a5, PVOID a6),
+ (a1, a2, a3, a4, a5, a6), FALSE);
+#undef SymEnumLinesW
+#define SymEnumLinesW RTLDRLAZY_FUNC_NAME(dbghelp, SymEnumLinesW)
+
+RTLDRLAZY_FUNC(dbghelp, BOOL, WINAPI, SymGetModuleInfo64, (HANDLE a1, DWORD64 a2, PIMAGEHLP_MODULE64 a3), (a1, a2, a3), FALSE);
+#undef SymGetModuleInfo64
+#define SymGetModuleInfo64 RTLDRLAZY_FUNC_NAME(dbghelp, SymGetModuleInfo64)
+
+
+
+
+#endif
+
diff --git a/include/iprt/x86.h b/include/iprt/x86.h
index 22b0b952..204a2ec1 100644
--- a/include/iprt/x86.h
+++ b/include/iprt/x86.h
@@ -161,16 +161,20 @@ typedef const X86RFLAGS *PCX86RFLAGS;
*/
/** Bit 0 - CF - Carry flag - Status flag. */
#define X86_EFL_CF RT_BIT(0)
+#define X86_EFL_CF_BIT 0
/** Bit 1 - Reserved, reads as 1. */
#define X86_EFL_1 RT_BIT(1)
/** Bit 2 - PF - Parity flag - Status flag. */
#define X86_EFL_PF RT_BIT(2)
/** Bit 4 - AF - Auxiliary carry flag - Status flag. */
#define X86_EFL_AF RT_BIT(4)
+#define X86_EFL_AF_BIT 4
/** Bit 6 - ZF - Zero flag - Status flag. */
#define X86_EFL_ZF RT_BIT(6)
+#define X86_EFL_ZF_BIT 6
/** Bit 7 - SF - Signed flag - Status flag. */
#define X86_EFL_SF RT_BIT(7)
+#define X86_EFL_SF_BIT 7
/** Bit 8 - TF - Trap flag - System flag. */
#define X86_EFL_TF RT_BIT(8)
/** Bit 9 - IF - Interrupt flag - System flag. */
@@ -179,6 +183,7 @@ typedef const X86RFLAGS *PCX86RFLAGS;
#define X86_EFL_DF RT_BIT(10)
/** Bit 11 - OF - Overflow flag - Status flag. */
#define X86_EFL_OF RT_BIT(11)
+#define X86_EFL_OF_BIT 11
/** Bit 12-13 - IOPL - I/O prvilege level flag - System flag. */
#define X86_EFL_IOPL (RT_BIT(12) | RT_BIT(13))
/** Bit 14 - NT - Nested task flag - System flag. */
@@ -195,12 +200,19 @@ typedef const X86RFLAGS *PCX86RFLAGS;
#define X86_EFL_VIP RT_BIT(20)
/** Bit 21 - ID - CPUID flag - System flag. If this responds to flipping CPUID is supported. */
#define X86_EFL_ID RT_BIT(21)
+/** All live bits. */
+#define X86_EFL_LIVE_MASK UINT32_C(0x003f7fd5)
+/** Read as 1 bits. */
+#define X86_EFL_RA1_MASK RT_BIT_32(1)
/** IOPL shift. */
#define X86_EFL_IOPL_SHIFT 12
/** The the IOPL level from the flags. */
#define X86_EFL_GET_IOPL(efl) (((efl) >> X86_EFL_IOPL_SHIFT) & 3)
/** Bits restored by popf */
-#define X86_EFL_POPF_BITS (X86_EFL_CF | X86_EFL_PF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_SF | X86_EFL_TF | X86_EFL_IF | X86_EFL_DF | X86_EFL_OF | X86_EFL_IOPL | X86_EFL_NT | X86_EFL_AC | X86_EFL_ID)
+#define X86_EFL_POPF_BITS ( X86_EFL_CF | X86_EFL_PF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_SF | X86_EFL_TF | X86_EFL_IF \
+ | X86_EFL_DF | X86_EFL_OF | X86_EFL_IOPL | X86_EFL_NT | X86_EFL_AC | X86_EFL_ID )
+/** The status bits commonly updated by arithmetic instructions. */
+#define X86_EFL_STATUS_BITS ( X86_EFL_CF | X86_EFL_PF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_SF | X86_EFL_OF )
/** @} */
@@ -437,6 +449,8 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
#define X86_CPUID_FEATURE_ECX_OSXSAVE RT_BIT(27)
/** ECX Bit 28 - AVX. */
#define X86_CPUID_FEATURE_ECX_AVX RT_BIT(28)
+/** ECX Bit 29 - F16C - Half-precision convert instruction support. */
+#define X86_CPUID_FEATURE_ECX_F16C RT_BIT(29)
/** ECX Bit 31 - Hypervisor Present (software only). */
#define X86_CPUID_FEATURE_ECX_HVP RT_BIT(31)
@@ -736,6 +750,8 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
#define X86_DR6_B2 RT_BIT(2)
/** Bit 3 - B3 - Breakpoint 3 condition detected. */
#define X86_DR6_B3 RT_BIT(3)
+/** Mask of all the Bx bits. */
+#define X86_DR6_B_MASK UINT64_C(0x0000000f)
/** Bit 13 - BD - Debug register access detected. Corresponds to the X86_DR7_GD bit. */
#define X86_DR6_BD RT_BIT(13)
/** Bit 14 - BS - Single step */
@@ -744,8 +760,17 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
#define X86_DR6_BT RT_BIT(15)
/** Value of DR6 after powerup/reset. */
#define X86_DR6_INIT_VAL UINT64_C(0xFFFF0FF0)
+/** Bits which must be 1s in DR6. */
+#define X86_DR6_RA1_MASK UINT64_C(0xffff0ff0)
+/** Bits which must be 0s in DR6. */
+#define X86_DR6_RAZ_MASK RT_BIT_64(12)
+/** Bits which must be 0s on writes to DR6. */
+#define X86_DR6_MBZ_MASK UINT64_C(0xffffffff00000000)
/** @} */
+/** Get the DR6.Bx bit for a the given breakpoint. */
+#define X86_DR6_B(iBp) RT_BIT_64(iBp)
+
/** @name DR7
* @{ */
@@ -770,6 +795,11 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
/** Bit 9 - GE - Local breakpoint exact. (Not supported (read ignored) by P6 and later.) */
#define X86_DR7_GE RT_BIT(9)
+/** L0, L1, L2, and L3. */
+#define X86_DR7_LE_ALL UINT64_C(0x0000000000000055)
+/** L0, L1, L2, and L3. */
+#define X86_DR7_GE_ALL UINT64_C(0x00000000000000aa)
+
/** Bit 13 - GD - General detect enable. Enables emulators to get exceptions when
* any DR register is accessed. */
#define X86_DR7_GD RT_BIT(13)
@@ -790,8 +820,12 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
/** Bit 30 & 31 - LEN3 - Length field 0. Values X86_DR7_LEN_*. */
#define X86_DR7_LEN3_MASK (3 << 30)
-/** Bits which must be 1s. */
-#define X86_DR7_MB1_MASK (RT_BIT(10))
+/** Bits which reads as 1s. */
+#define X86_DR7_RA1_MASK (RT_BIT(10))
+/** Bits which reads as zeros. */
+#define X86_DR7_RAZ_MASK UINT64_C(0x0000d800)
+/** Bits which must be 0s when writing to DR7. */
+#define X86_DR7_MBZ_MASK UINT64_C(0xffffffff00000000)
/** Calcs the L bit of Nth breakpoint.
* @param iBp The breakpoint number [0..3].
@@ -803,6 +837,11 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
*/
#define X86_DR7_G(iBp) ( UINT32_C(1) << (iBp * 2 + 1) )
+/** Calcs the L and G bits of Nth breakpoint.
+ * @param iBp The breakpoint number [0..3].
+ */
+#define X86_DR7_L_G(iBp) ( UINT32_C(3) << (iBp * 2) )
+
/** @name Read/Write values.
* @{ */
/** Break on instruction fetch only. */
@@ -821,6 +860,33 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
*/
#define X86_DR7_RW(iBp, fRw) ( (fRw) << ((iBp) * 4 + 16) )
+/** Fetch the the R/Wx bits for a given breakpoint (so it can be compared with
+ * one of the X86_DR7_RW_XXX constants).
+ *
+ * @returns X86_DR7_RW_XXX
+ * @param uDR7 DR7 value
+ * @param iBp The breakpoint number [0..3].
+ */
+#define X86_DR7_GET_RW(uDR7, iBp) ( ( (uDR7) >> ((iBp) * 4 + 16) ) & UINT32_C(3) )
+
+/** R/W0, R/W1, R/W2, and R/W3. */
+#define X86_DR7_RW_ALL_MASKS UINT32_C(0x33330000)
+
+/** Checks if there are any I/O breakpoint types configured in the RW
+ * registers. Does NOT check if these are enabled, sorry. */
+#define X86_DR7_ANY_RW_IO(uDR7) \
+ ( ( UINT32_C(0x22220000) & (uDR7) ) /* any candidates? */ \
+ && ( ( (UINT32_C(0x22220000) & (uDR7) ) >> 1 ) & ~(uDR7) ) )
+AssertCompile(X86_DR7_ANY_RW_IO(UINT32_C(0x33330000)) == 0);
+AssertCompile(X86_DR7_ANY_RW_IO(UINT32_C(0x22220000)) == 1);
+AssertCompile(X86_DR7_ANY_RW_IO(UINT32_C(0x32320000)) == 1);
+AssertCompile(X86_DR7_ANY_RW_IO(UINT32_C(0x23230000)) == 1);
+AssertCompile(X86_DR7_ANY_RW_IO(UINT32_C(0x00000000)) == 0);
+AssertCompile(X86_DR7_ANY_RW_IO(UINT32_C(0x00010000)) == 0);
+AssertCompile(X86_DR7_ANY_RW_IO(UINT32_C(0x00020000)) == 1);
+AssertCompile(X86_DR7_ANY_RW_IO(UINT32_C(0x00030000)) == 0);
+AssertCompile(X86_DR7_ANY_RW_IO(UINT32_C(0x00040000)) == 0);
+
/** @name Length values.
* @{ */
#define X86_DR7_LEN_BYTE 0U
@@ -839,13 +905,15 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
* @param uDR7 DR7 value
* @param iBp The breakpoint number [0..3].
*/
-#define X86_DR7_GET_LEN(uDR7, iBp) ( ( (uDR7) >> ((iBp) * 4 + 18) ) & 0x3U)
+#define X86_DR7_GET_LEN(uDR7, iBp) ( ( (uDR7) >> ((iBp) * 4 + 18) ) & UINT32_C(0x3) )
/** Mask used to check if any breakpoints are enabled. */
-#define X86_DR7_ENABLED_MASK (RT_BIT(0) | RT_BIT(1) | RT_BIT(2) | RT_BIT(3) | RT_BIT(4) | RT_BIT(5) | RT_BIT(6) | RT_BIT(7))
+#define X86_DR7_ENABLED_MASK UINT32_C(0x000000ff)
-/** Mask used to check if any io breakpoints are set. */
-#define X86_DR7_IO_ENABLED_MASK (X86_DR7_RW(0, X86_DR7_RW_IO) | X86_DR7_RW(1, X86_DR7_RW_IO) | X86_DR7_RW(2, X86_DR7_RW_IO) | X86_DR7_RW(3, X86_DR7_RW_IO))
+/** LEN0, LEN1, LEN2, and LEN3. */
+#define X86_DR7_LEN_ALL_MASKS UINT32_C(0xcccc0000)
+/** R/W0, R/W1, R/W2, R/W3,LEN0, LEN1, LEN2, and LEN3. */
+#define X86_DR7_RW_LEN_ALL_MASKS UINT32_C(0xffff0000)
/** Value of DR7 after powerup/reset. */
#define X86_DR7_INIT_VAL 0x400
@@ -855,19 +923,41 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
/** @name Machine Specific Registers
* @{
*/
-
+/** Machine check address register (P5). */
+#define MSR_P5_MC_ADDR UINT32_C(0x00000000)
+/** Machine check type register (P5). */
+#define MSR_P5_MC_TYPE UINT32_C(0x00000001)
/** Time Stamp Counter. */
#define MSR_IA32_TSC 0x10
+#define MSR_IA32_CESR UINT32_C(0x00000011)
+#define MSR_IA32_CTR0 UINT32_C(0x00000012)
+#define MSR_IA32_CTR1 UINT32_C(0x00000013)
#define MSR_IA32_PLATFORM_ID 0x17
#ifndef MSR_IA32_APICBASE /* qemu cpu.h kludge */
-#define MSR_IA32_APICBASE 0x1b
+# define MSR_IA32_APICBASE 0x1b
+/** Local APIC enabled. */
+# define MSR_IA32_APICBASE_EN RT_BIT_64(11)
+/** X2APIC enabled (requires the EN bit to be set). */
+# define MSR_IA32_APICBASE_EXTD RT_BIT_64(10)
+/** The processor is the boot strap processor (BSP). */
+# define MSR_IA32_APICBASE_BSP RT_BIT_64(8)
+/** Minimum base address mask, consult CPUID leaf 0x80000008 for the actual
+ * width. */
+# define MSR_IA32_APICBASE_BASE_MIN UINT64_C(0x0000000ffffff000)
#endif
+/** Undocumented intel MSR for reporting thread and core counts.
+ * Judging from the XNU sources, it seems to be introduced in Nehalem. The
+ * first 16 bits is the thread count. The next 16 bits the core count, except
+ * on Westmere where it seems it's only the next 4 bits for some reason. */
+#define MSR_CORE_THREAD_COUNT 0x35
+
/** CPU Feature control. */
#define MSR_IA32_FEATURE_CONTROL 0x3A
#define MSR_IA32_FEATURE_CONTROL_LOCK RT_BIT(0)
+#define MSR_IA32_FEATURE_CONTROL_SMX_VMXON RT_BIT(1)
#define MSR_IA32_FEATURE_CONTROL_VMXON RT_BIT(2)
/** BIOS update trigger (microcode update). */
@@ -891,9 +981,19 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
/** Get FSB clock status (Intel-specific). */
#define MSR_IA32_FSB_CLOCK_STS 0xCD
+/** C-State configuration control. Intel specific: Nehalem, Sandy Bridge. */
+#define MSR_PKG_CST_CONFIG_CONTROL UINT32_C(0x000000e2)
+
+/** C0 Maximum Frequency Clock Count */
+#define MSR_IA32_MPERF 0xE7
+/** C0 Actual Frequency Clock Count */
+#define MSR_IA32_APERF 0xE8
+
/** MTRR Capabilities. */
#define MSR_IA32_MTRR_CAP 0xFE
+/** Cache control/info. */
+#define MSR_BBL_CR_CTL3 UINT32_C(0x11e)
#ifndef MSR_IA32_SYSENTER_CS /* qemu cpu.h kludge */
/** SYSENTER_CS - the R0 CS, indirectly giving R0 SS, R3 CS and R3 DS.
@@ -909,14 +1009,11 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
#endif
/** Machine Check Global Capabilities Register. */
-#define MSR_IA32_MCP_CAP 0x179
+#define MSR_IA32_MCG_CAP 0x179
/** Machine Check Global Status Register. */
-#define MSR_IA32_MCP_STATUS 0x17A
+#define MSR_IA32_MCG_STATUS 0x17A
/** Machine Check Global Control Register. */
-#define MSR_IA32_MCP_CTRL 0x17B
-
-/** Trace/Profile Resource Control (R/W) */
-#define MSR_IA32_DEBUGCTL 0x1D9
+#define MSR_IA32_MCG_CTRL 0x17B
/** Page Attribute Table. */
#define MSR_IA32_CR_PAT 0x277
@@ -924,7 +1021,14 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
/** Performance counter MSRs. (Intel only) */
#define MSR_IA32_PERFEVTSEL0 0x186
#define MSR_IA32_PERFEVTSEL1 0x187
-#define MSR_IA32_FLEX_RATIO 0x194
+/** Flexible ratio, seems to be undocumented, used by XNU (tsc.c).
+ * The 16th bit whether flex ratio is being used, in which case bits 15:8
+ * holds a ratio that Apple takes for TSC granularity.
+ *
+ * @note This MSR conflics the P4 MSR_MCG_R12 register. */
+#define MSR_FLEX_RATIO 0x194
+/** Performance state value and starting with Intel core more.
+ * Apple uses the >=core features to determine TSC granularity on older CPUs. */
#define MSR_IA32_PERF_STATUS 0x198
#define MSR_IA32_PERF_CTL 0x199
#define MSR_IA32_THERM_STATUS 0x19c
@@ -932,25 +1036,39 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
/** Enable misc. processor features (R/W). */
#define MSR_IA32_MISC_ENABLE 0x1A0
/** Enable fast-strings feature (for REP MOVS and REP STORS). */
-#define MSR_IA32_MISC_ENABLE_FAST_STRINGS RT_BIT(0)
+#define MSR_IA32_MISC_ENABLE_FAST_STRINGS RT_BIT_64(0)
/** Automatic Thermal Control Circuit Enable (R/W). */
-#define MSR_IA32_MISC_ENABLE_TCC RT_BIT(3)
+#define MSR_IA32_MISC_ENABLE_TCC RT_BIT_64(3)
/** Performance Monitoring Available (R). */
-#define MSR_IA32_MISC_ENABLE_PERF_MON RT_BIT(7)
+#define MSR_IA32_MISC_ENABLE_PERF_MON RT_BIT_64(7)
/** Branch Trace Storage Unavailable (R/O). */
-#define MSR_IA32_MISC_ENABLE_BTS_UNAVAIL RT_BIT(11)
+#define MSR_IA32_MISC_ENABLE_BTS_UNAVAIL RT_BIT_64(11)
/** Precise Event Based Sampling (PEBS) Unavailable (R/O). */
-#define MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL RT_BIT(12)
+#define MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL RT_BIT_64(12)
/** Enhanced Intel SpeedStep Technology Enable (R/W). */
-#define MSR_IA32_MISC_ENABLE_SST_ENABLE RT_BIT(16)
+#define MSR_IA32_MISC_ENABLE_SST_ENABLE RT_BIT_64(16)
/** If MONITOR/MWAIT is supported (R/W). */
-#define MSR_IA32_MISC_ENABLE_MONITOR RT_BIT(18)
+#define MSR_IA32_MISC_ENABLE_MONITOR RT_BIT_64(18)
/** Limit CPUID Maxval to 3 leafs (R/W). */
-#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID RT_BIT(22)
+#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID RT_BIT_64(22)
/** When set to 1, xTPR messages are disabled (R/W). */
-#define MSR_IA32_MISC_ENABLE_XTPR_MSG_DISABLE RT_BIT(23)
+#define MSR_IA32_MISC_ENABLE_XTPR_MSG_DISABLE RT_BIT_64(23)
/** When set to 1, the Execute Disable Bit feature (XD Bit) is disabled (R/W). */
-#define MSR_IA32_MISC_ENABLE_XD_DISABLE RT_BIT(34)
+#define MSR_IA32_MISC_ENABLE_XD_DISABLE RT_BIT_64(34)
+
+/** Trace/Profile Resource Control (R/W) */
+#define MSR_IA32_DEBUGCTL UINT32_C(0x000001d9)
+/** The number (0..3 or 0..15) of the last branch record register on P4 and
+ * related Xeons. */
+#define MSR_P4_LASTBRANCH_TOS UINT32_C(0x000001da)
+/** @name Last branch registers for P4 and Xeon, models 0 thru 2.
+ * @{ */
+#define MSR_P4_LASTBRANCH_0 UINT32_C(0x000001db)
+#define MSR_P4_LASTBRANCH_1 UINT32_C(0x000001dc)
+#define MSR_P4_LASTBRANCH_2 UINT32_C(0x000001dd)
+#define MSR_P4_LASTBRANCH_3 UINT32_C(0x000001de)
+/** @} */
+
#define IA32_MTRR_PHYSBASE0 0x200
#define IA32_MTRR_PHYSMASK0 0x201
@@ -1016,18 +1134,23 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
#define MSR_IA32_VMX_CR4_FIXED1 0x489
/** Information for enumerating fields in the VMCS. */
#define MSR_IA32_VMX_VMCS_ENUM 0x48A
+/** Allowed settings for the VM-functions controls. */
+#define MSR_IA32_VMX_VMFUNC 0x491
/** Allowed settings for secondary proc-based VM execution controls */
#define MSR_IA32_VMX_PROCBASED_CTLS2 0x48B
/** EPT capabilities. */
-#define MSR_IA32_VMX_EPT_CAPS 0x48C
+#define MSR_IA32_VMX_EPT_VPID_CAP 0x48C
/** DS Save Area (R/W). */
#define MSR_IA32_DS_AREA 0x600
+/** Running Average Power Limit (RAPL) power units. */
+#define MSR_RAPL_POWER_UNIT 0x606
/** X2APIC MSR ranges. */
-#define MSR_IA32_APIC_START 0x800
-#define MSR_IA32_APIC_END 0x900
+#define MSR_IA32_X2APIC_START 0x800
+#define MSR_IA32_X2APIC_TPR 0x808
+#define MSR_IA32_X2APIC_END 0xBFF
/** K6 EFER - Extended Feature Enable Register. */
-#define MSR_K6_EFER 0xc0000080
+#define MSR_K6_EFER UINT32_C(0xc0000080)
/** @todo document EFER */
/** Bit 0 - SCE - System call extensions (SYSCALL / SYSRET). (R/W) */
#define MSR_K6_EFER_SCE RT_BIT(0)
@@ -1044,65 +1167,71 @@ typedef const X86CPUIDFEATEDX *PCX86CPUIDFEATEDX;
/** Bit 14 - FFXSR - Fast FXSAVE / FXRSTOR (skip XMM*). (R/W) */
#define MSR_K6_EFER_FFXSR RT_BIT(14)
/** K6 STAR - SYSCALL/RET targets. */
-#define MSR_K6_STAR 0xc0000081
+#define MSR_K6_STAR UINT32_C(0xc0000081)
/** Shift value for getting the SYSRET CS and SS value. */
#define MSR_K6_STAR_SYSRET_CS_SS_SHIFT 48
/** Shift value for getting the SYSCALL CS and SS value. */
#define MSR_K6_STAR_SYSCALL_CS_SS_SHIFT 32
/** Selector mask for use after shifting. */
-#define MSR_K6_STAR_SEL_MASK 0xffff
+#define MSR_K6_STAR_SEL_MASK UINT32_C(0xffff)
/** The mask which give the SYSCALL EIP. */
-#define MSR_K6_STAR_SYSCALL_EIP_MASK 0xffffffff
+#define MSR_K6_STAR_SYSCALL_EIP_MASK UINT32_C(0xffffffff)
/** K6 WHCR - Write Handling Control Register. */
-#define MSR_K6_WHCR 0xc0000082
+#define MSR_K6_WHCR UINT32_C(0xc0000082)
/** K6 UWCCR - UC/WC Cacheability Control Register. */
-#define MSR_K6_UWCCR 0xc0000085
+#define MSR_K6_UWCCR UINT32_C(0xc0000085)
/** K6 PSOR - Processor State Observability Register. */
-#define MSR_K6_PSOR 0xc0000087
+#define MSR_K6_PSOR UINT32_C(0xc0000087)
/** K6 PFIR - Page Flush/Invalidate Register. */
-#define MSR_K6_PFIR 0xc0000088
+#define MSR_K6_PFIR UINT32_C(0xc0000088)
/** Performance counter MSRs. (AMD only) */
-#define MSR_K7_EVNTSEL0 0xc0010000
-#define MSR_K7_EVNTSEL1 0xc0010001
-#define MSR_K7_EVNTSEL2 0xc0010002
-#define MSR_K7_EVNTSEL3 0xc0010003
-#define MSR_K7_PERFCTR0 0xc0010004
-#define MSR_K7_PERFCTR1 0xc0010005
-#define MSR_K7_PERFCTR2 0xc0010006
-#define MSR_K7_PERFCTR3 0xc0010007
+#define MSR_K7_EVNTSEL0 UINT32_C(0xc0010000)
+#define MSR_K7_EVNTSEL1 UINT32_C(0xc0010001)
+#define MSR_K7_EVNTSEL2 UINT32_C(0xc0010002)
+#define MSR_K7_EVNTSEL3 UINT32_C(0xc0010003)
+#define MSR_K7_PERFCTR0 UINT32_C(0xc0010004)
+#define MSR_K7_PERFCTR1 UINT32_C(0xc0010005)
+#define MSR_K7_PERFCTR2 UINT32_C(0xc0010006)
+#define MSR_K7_PERFCTR3 UINT32_C(0xc0010007)
/** K8 LSTAR - Long mode SYSCALL target (RIP). */
-#define MSR_K8_LSTAR 0xc0000082
+#define MSR_K8_LSTAR UINT32_C(0xc0000082)
/** K8 CSTAR - Compatibility mode SYSCALL target (RIP). */
-#define MSR_K8_CSTAR 0xc0000083
+#define MSR_K8_CSTAR UINT32_C(0xc0000083)
/** K8 SF_MASK - SYSCALL flag mask. (aka SFMASK) */
-#define MSR_K8_SF_MASK 0xc0000084
+#define MSR_K8_SF_MASK UINT32_C(0xc0000084)
/** K8 FS.base - The 64-bit base FS register. */
-#define MSR_K8_FS_BASE 0xc0000100
+#define MSR_K8_FS_BASE UINT32_C(0xc0000100)
/** K8 GS.base - The 64-bit base GS register. */
-#define MSR_K8_GS_BASE 0xc0000101
+#define MSR_K8_GS_BASE UINT32_C(0xc0000101)
/** K8 KernelGSbase - Used with SWAPGS. */
-#define MSR_K8_KERNEL_GS_BASE 0xc0000102
+#define MSR_K8_KERNEL_GS_BASE UINT32_C(0xc0000102)
/** K8 TSC_AUX - Used with RDTSCP. */
-#define MSR_K8_TSC_AUX 0xc0000103
-#define MSR_K8_SYSCFG 0xc0010010
-#define MSR_K8_HWCR 0xc0010015
-#define MSR_K8_IORRBASE0 0xc0010016
-#define MSR_K8_IORRMASK0 0xc0010017
-#define MSR_K8_IORRBASE1 0xc0010018
-#define MSR_K8_IORRMASK1 0xc0010019
-#define MSR_K8_TOP_MEM1 0xc001001a
-#define MSR_K8_TOP_MEM2 0xc001001d
-#define MSR_K8_VM_CR 0xc0010114
+#define MSR_K8_TSC_AUX UINT32_C(0xc0000103)
+#define MSR_K8_SYSCFG UINT32_C(0xc0010010)
+#define MSR_K8_HWCR UINT32_C(0xc0010015)
+#define MSR_K8_IORRBASE0 UINT32_C(0xc0010016)
+#define MSR_K8_IORRMASK0 UINT32_C(0xc0010017)
+#define MSR_K8_IORRBASE1 UINT32_C(0xc0010018)
+#define MSR_K8_IORRMASK1 UINT32_C(0xc0010019)
+#define MSR_K8_TOP_MEM1 UINT32_C(0xc001001a)
+#define MSR_K8_TOP_MEM2 UINT32_C(0xc001001d)
+/** North bridge config? See BIOS & Kernel dev guides for
+ * details. */
+#define MSR_K8_NB_CFG UINT32_C(0xc001001f)
+
+/** Hypertransport interrupt pending register.
+ * "BIOS and Kernel Developer's Guide for AMD NPT Family 0Fh Processors" */
+#define MSR_K8_INT_PENDING UINT32_C(0xc0010055)
+#define MSR_K8_VM_CR UINT32_C(0xc0010114)
#define MSR_K8_VM_CR_SVM_DISABLE RT_BIT(4)
-#define MSR_K8_IGNNE 0xc0010115
-#define MSR_K8_SMM_CTL 0xc0010116
+#define MSR_K8_IGNNE UINT32_C(0xc0010115)
+#define MSR_K8_SMM_CTL UINT32_C(0xc0010116)
/** SVM - VM_HSAVE_PA - Physical address for saving and restoring
- * host state during world switch.
- */
-#define MSR_K8_VM_HSAVE_PA 0xc0010117
+ * host state during world switch. */
+#define MSR_K8_VM_HSAVE_PA UINT32_C(0xc0010117)
/** @} */
@@ -1173,6 +1302,10 @@ typedef X86PGPAEUINT const *PCX86PGPAEUINT;
/** The 4MB page base mask for virtual addresses - 32bit version. */
#define X86_PAGE_4M_BASE_MASK_32 0xffc00000U
+/**
+ * Check if the given address is canonical.
+ */
+#define X86_IS_CANONICAL(a_u64Addr) ((uint64_t)(a_u64Addr) + UINT64_C(0x800000000000) < UINT64_C(0x1000000000000))
/** @name Page Table Entry
@@ -2219,6 +2352,55 @@ typedef const X86FXSTATE *PCX86FXSTATE;
#define X86_FCW_ZERO_MASK UINT16_C(0xf080)
/** @} */
+/** @name SSE MXCSR
+ * @{ */
+/** Exception Flag: Invalid operation. */
+#define X86_MSXCR_IE RT_BIT(0)
+/** Exception Flag: Denormalized operand. */
+#define X86_MSXCR_DE RT_BIT(1)
+/** Exception Flag: Zero divide. */
+#define X86_MSXCR_ZE RT_BIT(2)
+/** Exception Flag: Overflow. */
+#define X86_MSXCR_OE RT_BIT(3)
+/** Exception Flag: Underflow. */
+#define X86_MSXCR_UE RT_BIT(4)
+/** Exception Flag: Precision. */
+#define X86_MSXCR_PE RT_BIT(5)
+
+/** Denormals are zero. */
+#define X86_MSXCR_DAZ RT_BIT(6)
+
+/** Exception Mask: Invalid operation. */
+#define X86_MSXCR_IM RT_BIT(7)
+/** Exception Mask: Denormalized operand. */
+#define X86_MSXCR_DM RT_BIT(8)
+/** Exception Mask: Zero divide. */
+#define X86_MSXCR_ZM RT_BIT(9)
+/** Exception Mask: Overflow. */
+#define X86_MSXCR_OM RT_BIT(10)
+/** Exception Mask: Underflow. */
+#define X86_MSXCR_UM RT_BIT(11)
+/** Exception Mask: Precision. */
+#define X86_MSXCR_PM RT_BIT(12)
+
+/** Rounding control mask. */
+#define X86_MSXCR_RC_MASK UINT16_C(0x6000)
+/** Rounding control: To nearest. */
+#define X86_MSXCR_RC_NEAREST UINT16_C(0x0000)
+/** Rounding control: Down. */
+#define X86_MSXCR_RC_DOWN UINT16_C(0x2000)
+/** Rounding control: Up. */
+#define X86_MSXCR_RC_UP UINT16_C(0x4000)
+/** Rounding control: Towards zero. */
+#define X86_MSXCR_RC_ZERO UINT16_C(0x6000)
+
+/** Flush-to-zero for masked underflow. */
+#define X86_MSXCR_FZ RT_BIT(15)
+
+/** Misaligned Exception Mask. */
+#define X86_MSXCR_MM RT_BIT(16)
+/** @} */
+
/** @name Selector Descriptor
* @{
@@ -2226,7 +2408,7 @@ typedef const X86FXSTATE *PCX86FXSTATE;
#ifndef VBOX_FOR_DTRACE_LIB
/**
- * Descriptor attributes.
+ * Descriptor attributes (as seen by VT-x).
*/
typedef struct X86DESCATTRBITS
{
@@ -2250,9 +2432,26 @@ typedef struct X86DESCATTRBITS
/** 0f - Granularity of the limit. If set 4KB granularity is used, if
* clear byte. */
unsigned u1Granularity : 1;
+ /** 10 - "Unusable" selector, special Intel (VT-x only?) bit. */
+ unsigned u1Unusable : 1;
} X86DESCATTRBITS;
#endif /* !VBOX_FOR_DTRACE_LIB */
+/** @name X86DESCATTR masks
+ * @{ */
+#define X86DESCATTR_TYPE UINT32_C(0x0000000f)
+#define X86DESCATTR_DT UINT32_C(0x00000010)
+#define X86DESCATTR_DPL UINT32_C(0x00000060)
+#define X86DESCATTR_DPL_SHIFT 5 /**< Shift count for the DPL value. */
+#define X86DESCATTR_P UINT32_C(0x00000080)
+#define X86DESCATTR_LIMIT_HIGH UINT32_C(0x00000f00)
+#define X86DESCATTR_AVL UINT32_C(0x00001000)
+#define X86DESCATTR_L UINT32_C(0x00002000)
+#define X86DESCATTR_D UINT32_C(0x00004000)
+#define X86DESCATTR_G UINT32_C(0x00008000)
+#define X86DESCATTR_UNUSABLE UINT32_C(0x00010000)
+/** @} */
+
#pragma pack(1)
typedef union X86DESCATTR
{
@@ -2277,34 +2476,34 @@ typedef const X86DESCATTR *PCX86DESCATTR;
#pragma pack(1)
typedef struct X86DESCGENERIC
{
- /** Limit - Low word. */
+ /** 00 - Limit - Low word. */
unsigned u16LimitLow : 16;
- /** Base address - lowe word.
+ /** 10 - Base address - lowe word.
* Don't try set this to 24 because MSC is doing stupid things then. */
unsigned u16BaseLow : 16;
- /** Base address - first 8 bits of high word. */
+ /** 20 - Base address - first 8 bits of high word. */
unsigned u8BaseHigh1 : 8;
- /** Segment Type. */
+ /** 28 - Segment Type. */
unsigned u4Type : 4;
- /** Descriptor Type. System(=0) or code/data selector */
+ /** 2c - Descriptor Type. System(=0) or code/data selector */
unsigned u1DescType : 1;
- /** Descriptor Privelege level. */
+ /** 2d - Descriptor Privelege level. */
unsigned u2Dpl : 2;
- /** Flags selector present(=1) or not. */
+ /** 2f - Flags selector present(=1) or not. */
unsigned u1Present : 1;
- /** Segment limit 16-19. */
+ /** 30 - Segment limit 16-19. */
unsigned u4LimitHigh : 4;
- /** Available for system software. */
+ /** 34 - Available for system software. */
unsigned u1Available : 1;
- /** 32 bits mode: Reserved - 0, long mode: Long Attribute Bit. */
+ /** 35 - 32 bits mode: Reserved - 0, long mode: Long Attribute Bit. */
unsigned u1Long : 1;
- /** This flags meaning depends on the segment type. Try make sense out
+ /** 36 - This flags meaning depends on the segment type. Try make sense out
* of the intel manual yourself. */
unsigned u1DefBig : 1;
- /** Granularity of the limit. If set 4KB granularity is used, if
+ /** 37 - Granularity of the limit. If set 4KB granularity is used, if
* clear byte. */
unsigned u1Granularity : 1;
- /** Base address - highest 8 bits. */
+ /** 38 - Base address - highest 8 bits. */
unsigned u8BaseHigh2 : 8;
} X86DESCGENERIC;
#pragma pack()
@@ -3041,7 +3240,7 @@ typedef enum X86XCPT
X86_XCPT_GP = 0x0d,
/** \#PF - Page fault. */
X86_XCPT_PF = 0x0e,
- /* 0x0f is reserved. */
+ /* 0x0f is reserved (to avoid conflict with spurious interrupts in BIOS setup). */
/** \#MF - Math fault (FPU). */
X86_XCPT_MF = 0x10,
/** \#AC - Alignment check. */
@@ -3049,12 +3248,18 @@ typedef enum X86XCPT
/** \#MC - Machine check. */
X86_XCPT_MC = 0x12,
/** \#XF - SIMD Floating-Pointer Exception. */
- X86_XCPT_XF = 0x13
+ X86_XCPT_XF = 0x13,
+ /** \#VE - Virtualzation Exception. */
+ X86_XCPT_VE = 0x14,
+ /** \#SX - Security Exception. */
+ X86_XCPT_SX = 0x1f
} X86XCPT;
/** Pointer to a x86 exception code. */
typedef X86XCPT *PX86XCPT;
/** Pointer to a const x86 exception code. */
typedef const X86XCPT *PCX86XCPT;
+/** The maximum exception value. */
+#define X86_XCPT_MAX (X86_XCPT_SX)
/** @name Trap Error Codes
@@ -3090,6 +3295,19 @@ typedef const X86XCPT *PCX86XCPT;
#pragma pack(1)
/**
+ * 16-bit IDTR.
+ */
+typedef struct X86IDTR16
+{
+ /** Offset. */
+ uint16_t offSel;
+ /** Selector. */
+ uint16_t uSel;
+} X86IDTR16, *PX86IDTR16;
+#pragma pack()
+
+#pragma pack(1)
+/**
* 32-bit IDTR/GDTR.
*/
typedef struct X86XDTR32
@@ -3188,6 +3406,26 @@ AssertCompile((X86_SIB_SCALE_MASK >> X86_SIB_SCALE_SHIFT) == X86_SIB_SCALE_SMASK
#define X86_SREG_COUNT 6
+/** @name X86_OP_XXX - Prefixes
+ * @{ */
+#define X86_OP_PRF_CS UINT8_C(0x2e)
+#define X86_OP_PRF_SS UINT8_C(0x36)
+#define X86_OP_PRF_DS UINT8_C(0x3e)
+#define X86_OP_PRF_ES UINT8_C(0x26)
+#define X86_OP_PRF_FS UINT8_C(0x64)
+#define X86_OP_PRF_GS UINT8_C(0x65)
+#define X86_OP_PRF_SIZE_OP UINT8_C(0x66)
+#define X86_OP_PRF_SIZE_ADDR UINT8_C(0x67)
+#define X86_OP_PRF_LOCK UINT8_C(0xf0)
+#define X86_OP_PRF_REPZ UINT8_C(0xf2)
+#define X86_OP_PRF_REPNZ UINT8_C(0xf3)
+#define X86_OP_REX_B UINT8_C(0x41)
+#define X86_OP_REX_X UINT8_C(0x42)
+#define X86_OP_REX_R UINT8_C(0x44)
+#define X86_OP_REX_W UINT8_C(0x48)
+/** @} */
+
+
/** @} */
#endif
diff --git a/include/iprt/x86.mac b/include/iprt/x86.mac
index d9765261..bf10b660 100644
--- a/include/iprt/x86.mac
+++ b/include/iprt/x86.mac
@@ -12,15 +12,20 @@
%ifndef VBOX_FOR_DTRACE_LIB
%endif
%define X86_EFL_CF RT_BIT(0)
+%define X86_EFL_CF_BIT 0
%define X86_EFL_1 RT_BIT(1)
%define X86_EFL_PF RT_BIT(2)
%define X86_EFL_AF RT_BIT(4)
+%define X86_EFL_AF_BIT 4
%define X86_EFL_ZF RT_BIT(6)
+%define X86_EFL_ZF_BIT 6
%define X86_EFL_SF RT_BIT(7)
+%define X86_EFL_SF_BIT 7
%define X86_EFL_TF RT_BIT(8)
%define X86_EFL_IF RT_BIT(9)
%define X86_EFL_DF RT_BIT(10)
%define X86_EFL_OF RT_BIT(11)
+%define X86_EFL_OF_BIT 11
%define X86_EFL_IOPL (RT_BIT(12) | RT_BIT(13))
%define X86_EFL_NT RT_BIT(14)
%define X86_EFL_RF RT_BIT(16)
@@ -29,9 +34,13 @@
%define X86_EFL_VIF RT_BIT(19)
%define X86_EFL_VIP RT_BIT(20)
%define X86_EFL_ID RT_BIT(21)
+%define X86_EFL_LIVE_MASK 0x003f7fd5
+%define X86_EFL_RA1_MASK RT_BIT_32(1)
%define X86_EFL_IOPL_SHIFT 12
%define X86_EFL_GET_IOPL(efl) (((efl) >> X86_EFL_IOPL_SHIFT) & 3)
-%define X86_EFL_POPF_BITS (X86_EFL_CF | X86_EFL_PF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_SF | X86_EFL_TF | X86_EFL_IF | X86_EFL_DF | X86_EFL_OF | X86_EFL_IOPL | X86_EFL_NT | X86_EFL_AC | X86_EFL_ID)
+%define X86_EFL_POPF_BITS ( X86_EFL_CF | X86_EFL_PF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_SF | X86_EFL_TF | X86_EFL_IF \
+ | X86_EFL_DF | X86_EFL_OF | X86_EFL_IOPL | X86_EFL_NT | X86_EFL_AC | X86_EFL_ID )
+%define X86_EFL_STATUS_BITS ( X86_EFL_CF | X86_EFL_PF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_SF | X86_EFL_OF )
%ifndef VBOX_FOR_DTRACE_LIB
%else
%endif
@@ -74,6 +83,7 @@
%define X86_CPUID_FEATURE_ECX_XSAVE RT_BIT(26)
%define X86_CPUID_FEATURE_ECX_OSXSAVE RT_BIT(27)
%define X86_CPUID_FEATURE_ECX_AVX RT_BIT(28)
+%define X86_CPUID_FEATURE_ECX_F16C RT_BIT(29)
%define X86_CPUID_FEATURE_ECX_HVP RT_BIT(31)
%define X86_CPUID_FEATURE_EDX_FPU RT_BIT(0)
%define X86_CPUID_FEATURE_EDX_VME RT_BIT(1)
@@ -203,10 +213,15 @@
%define X86_DR6_B1 RT_BIT(1)
%define X86_DR6_B2 RT_BIT(2)
%define X86_DR6_B3 RT_BIT(3)
+%define X86_DR6_B_MASK 0x0000000f
%define X86_DR6_BD RT_BIT(13)
%define X86_DR6_BS RT_BIT(14)
%define X86_DR6_BT RT_BIT(15)
%define X86_DR6_INIT_VAL 0xFFFF0FF0
+%define X86_DR6_RA1_MASK 0xffff0ff0
+%define X86_DR6_RAZ_MASK RT_BIT_64(12)
+%define X86_DR6_MBZ_MASK 0xffffffff00000000
+%define X86_DR6_B(iBp) RT_BIT_64(iBp)
%define X86_DR7_L0 RT_BIT(0)
%define X86_DR7_G0 RT_BIT(1)
%define X86_DR7_L1 RT_BIT(2)
@@ -217,6 +232,8 @@
%define X86_DR7_G3 RT_BIT(7)
%define X86_DR7_LE RT_BIT(8)
%define X86_DR7_GE RT_BIT(9)
+%define X86_DR7_LE_ALL 0x0000000000000055
+%define X86_DR7_GE_ALL 0x00000000000000aa
%define X86_DR7_GD RT_BIT(13)
%define X86_DR7_RW0_MASK (3 << 16)
%define X86_DR7_LEN0_MASK (3 << 18)
@@ -226,30 +243,49 @@
%define X86_DR7_LEN2_MASK (3 << 26)
%define X86_DR7_RW3_MASK (3 << 28)
%define X86_DR7_LEN3_MASK (3 << 30)
-%define X86_DR7_MB1_MASK (RT_BIT(10))
+%define X86_DR7_RA1_MASK (RT_BIT(10))
+%define X86_DR7_RAZ_MASK 0x0000d800
+%define X86_DR7_MBZ_MASK 0xffffffff00000000
%define X86_DR7_L(iBp) ( 1 << (iBp * 2) )
%define X86_DR7_G(iBp) ( 1 << (iBp * 2 + 1) )
+%define X86_DR7_L_G(iBp) ( 3 << (iBp * 2) )
%define X86_DR7_RW_EO 0
%define X86_DR7_RW_WO 1
%define X86_DR7_RW_IO 2
%define X86_DR7_RW_RW 3
%define X86_DR7_RW(iBp, fRw) ( (fRw) << ((iBp) * 4 + 16) )
+%define X86_DR7_GET_RW(uDR7, iBp) ( ( (uDR7) >> ((iBp) * 4 + 16) ) & 3 )
+%define X86_DR7_RW_ALL_MASKS 0x33330000
+%define X86_DR7_ANY_RW_IO(uDR7) \
+ ( ( 0x22220000 & (uDR7) )
%define X86_DR7_LEN_BYTE 0
%define X86_DR7_LEN_WORD 1
%define X86_DR7_LEN_QWORD 2
%define X86_DR7_LEN_DWORD 3
%define X86_DR7_LEN(iBp, cb) ( (cb) << ((iBp) * 4 + 18) )
-%define X86_DR7_GET_LEN(uDR7, iBp) ( ( (uDR7) >> ((iBp) * 4 + 18) ) & 0x3)
-%define X86_DR7_ENABLED_MASK (RT_BIT(0) | RT_BIT(1) | RT_BIT(2) | RT_BIT(3) | RT_BIT(4) | RT_BIT(5) | RT_BIT(6) | RT_BIT(7))
-%define X86_DR7_IO_ENABLED_MASK (X86_DR7_RW(0, X86_DR7_RW_IO) | X86_DR7_RW(1, X86_DR7_RW_IO) | X86_DR7_RW(2, X86_DR7_RW_IO) | X86_DR7_RW(3, X86_DR7_RW_IO))
+%define X86_DR7_GET_LEN(uDR7, iBp) ( ( (uDR7) >> ((iBp) * 4 + 18) ) & 0x3 )
+%define X86_DR7_ENABLED_MASK 0x000000ff
+%define X86_DR7_LEN_ALL_MASKS 0xcccc0000
+%define X86_DR7_RW_LEN_ALL_MASKS 0xffff0000
%define X86_DR7_INIT_VAL 0x400
+%define MSR_P5_MC_ADDR 0x00000000
+%define MSR_P5_MC_TYPE 0x00000001
%define MSR_IA32_TSC 0x10
+%define MSR_IA32_CESR 0x00000011
+%define MSR_IA32_CTR0 0x00000012
+%define MSR_IA32_CTR1 0x00000013
%define MSR_IA32_PLATFORM_ID 0x17
%ifndef MSR_IA32_APICBASE
-%define MSR_IA32_APICBASE 0x1b
+ %define MSR_IA32_APICBASE 0x1b
+ %define MSR_IA32_APICBASE_EN RT_BIT_64(11)
+ %define MSR_IA32_APICBASE_EXTD RT_BIT_64(10)
+ %define MSR_IA32_APICBASE_BSP RT_BIT_64(8)
+ %define MSR_IA32_APICBASE_BASE_MIN 0x0000000ffffff000
%endif
+%define MSR_CORE_THREAD_COUNT 0x35
%define MSR_IA32_FEATURE_CONTROL 0x3A
%define MSR_IA32_FEATURE_CONTROL_LOCK RT_BIT(0)
+%define MSR_IA32_FEATURE_CONTROL_SMX_VMXON RT_BIT(1)
%define MSR_IA32_FEATURE_CONTROL_VMXON RT_BIT(2)
%define MSR_IA32_BIOS_UPDT_TRIG 0x79
%define MSR_IA32_BIOS_SIGN_ID 0x8B
@@ -259,34 +295,43 @@
%define MSR_IA32_PMC3 0xC4
%define MSR_IA32_PLATFORM_INFO 0xCE
%define MSR_IA32_FSB_CLOCK_STS 0xCD
+%define MSR_PKG_CST_CONFIG_CONTROL 0x000000e2
+%define MSR_IA32_MPERF 0xE7
+%define MSR_IA32_APERF 0xE8
%define MSR_IA32_MTRR_CAP 0xFE
+%define MSR_BBL_CR_CTL3 0x11e
%ifndef MSR_IA32_SYSENTER_CS
%define MSR_IA32_SYSENTER_CS 0x174
%define MSR_IA32_SYSENTER_ESP 0x175
%define MSR_IA32_SYSENTER_EIP 0x176
%endif
-%define MSR_IA32_MCP_CAP 0x179
-%define MSR_IA32_MCP_STATUS 0x17A
-%define MSR_IA32_MCP_CTRL 0x17B
-%define MSR_IA32_DEBUGCTL 0x1D9
+%define MSR_IA32_MCG_CAP 0x179
+%define MSR_IA32_MCG_STATUS 0x17A
+%define MSR_IA32_MCG_CTRL 0x17B
%define MSR_IA32_CR_PAT 0x277
%define MSR_IA32_PERFEVTSEL0 0x186
%define MSR_IA32_PERFEVTSEL1 0x187
-%define MSR_IA32_FLEX_RATIO 0x194
+%define MSR_FLEX_RATIO 0x194
%define MSR_IA32_PERF_STATUS 0x198
%define MSR_IA32_PERF_CTL 0x199
%define MSR_IA32_THERM_STATUS 0x19c
%define MSR_IA32_MISC_ENABLE 0x1A0
-%define MSR_IA32_MISC_ENABLE_FAST_STRINGS RT_BIT(0)
-%define MSR_IA32_MISC_ENABLE_TCC RT_BIT(3)
-%define MSR_IA32_MISC_ENABLE_PERF_MON RT_BIT(7)
-%define MSR_IA32_MISC_ENABLE_BTS_UNAVAIL RT_BIT(11)
-%define MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL RT_BIT(12)
-%define MSR_IA32_MISC_ENABLE_SST_ENABLE RT_BIT(16)
-%define MSR_IA32_MISC_ENABLE_MONITOR RT_BIT(18)
-%define MSR_IA32_MISC_ENABLE_LIMIT_CPUID RT_BIT(22)
-%define MSR_IA32_MISC_ENABLE_XTPR_MSG_DISABLE RT_BIT(23)
-%define MSR_IA32_MISC_ENABLE_XD_DISABLE RT_BIT(34)
+%define MSR_IA32_MISC_ENABLE_FAST_STRINGS RT_BIT_64(0)
+%define MSR_IA32_MISC_ENABLE_TCC RT_BIT_64(3)
+%define MSR_IA32_MISC_ENABLE_PERF_MON RT_BIT_64(7)
+%define MSR_IA32_MISC_ENABLE_BTS_UNAVAIL RT_BIT_64(11)
+%define MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL RT_BIT_64(12)
+%define MSR_IA32_MISC_ENABLE_SST_ENABLE RT_BIT_64(16)
+%define MSR_IA32_MISC_ENABLE_MONITOR RT_BIT_64(18)
+%define MSR_IA32_MISC_ENABLE_LIMIT_CPUID RT_BIT_64(22)
+%define MSR_IA32_MISC_ENABLE_XTPR_MSG_DISABLE RT_BIT_64(23)
+%define MSR_IA32_MISC_ENABLE_XD_DISABLE RT_BIT_64(34)
+%define MSR_IA32_DEBUGCTL 0x000001d9
+%define MSR_P4_LASTBRANCH_TOS 0x000001da
+%define MSR_P4_LASTBRANCH_0 0x000001db
+%define MSR_P4_LASTBRANCH_1 0x000001dc
+%define MSR_P4_LASTBRANCH_2 0x000001dd
+%define MSR_P4_LASTBRANCH_3 0x000001de
%define IA32_MTRR_PHYSBASE0 0x200
%define IA32_MTRR_PHYSMASK0 0x201
%define IA32_MTRR_PHYSBASE1 0x202
@@ -332,11 +377,14 @@
%define MSR_IA32_VMX_CR4_FIXED0 0x488
%define MSR_IA32_VMX_CR4_FIXED1 0x489
%define MSR_IA32_VMX_VMCS_ENUM 0x48A
+%define MSR_IA32_VMX_VMFUNC 0x491
%define MSR_IA32_VMX_PROCBASED_CTLS2 0x48B
-%define MSR_IA32_VMX_EPT_CAPS 0x48C
+%define MSR_IA32_VMX_EPT_VPID_CAP 0x48C
%define MSR_IA32_DS_AREA 0x600
-%define MSR_IA32_APIC_START 0x800
-%define MSR_IA32_APIC_END 0x900
+%define MSR_RAPL_POWER_UNIT 0x606
+%define MSR_IA32_X2APIC_START 0x800
+%define MSR_IA32_X2APIC_TPR 0x808
+%define MSR_IA32_X2APIC_END 0xBFF
%define MSR_K6_EFER 0xc0000080
%define MSR_K6_EFER_SCE RT_BIT(0)
%define MSR_K6_EFER_LME RT_BIT(8)
@@ -377,6 +425,8 @@
%define MSR_K8_IORRMASK1 0xc0010019
%define MSR_K8_TOP_MEM1 0xc001001a
%define MSR_K8_TOP_MEM2 0xc001001d
+%define MSR_K8_NB_CFG 0xc001001f
+%define MSR_K8_INT_PENDING 0xc0010055
%define MSR_K8_VM_CR 0xc0010114
%define MSR_K8_VM_CR_SVM_DISABLE RT_BIT(4)
%define MSR_K8_IGNNE 0xc0010115
@@ -402,6 +452,7 @@
%define X86_PAGE_4M_OFFSET_MASK 0x003fffff
%define X86_PAGE_4M_BASE_MASK 0xffffffffffc00000
%define X86_PAGE_4M_BASE_MASK_32 0xffc00000
+%define X86_IS_CANONICAL(a_u64Addr) ((uint64_t)(a_u64Addr) + 0x800000000000 < UINT64_C(0x1000000000000))
%define X86_PTE_BIT_P 0
%define X86_PTE_BIT_RW 1
%define X86_PTE_BIT_US 2
@@ -543,8 +594,39 @@
%define X86_FCW_RC_UP 0x0800
%define X86_FCW_RC_ZERO 0x0c00
%define X86_FCW_ZERO_MASK 0xf080
+%define X86_MSXCR_IE RT_BIT(0)
+%define X86_MSXCR_DE RT_BIT(1)
+%define X86_MSXCR_ZE RT_BIT(2)
+%define X86_MSXCR_OE RT_BIT(3)
+%define X86_MSXCR_UE RT_BIT(4)
+%define X86_MSXCR_PE RT_BIT(5)
+%define X86_MSXCR_DAZ RT_BIT(6)
+%define X86_MSXCR_IM RT_BIT(7)
+%define X86_MSXCR_DM RT_BIT(8)
+%define X86_MSXCR_ZM RT_BIT(9)
+%define X86_MSXCR_OM RT_BIT(10)
+%define X86_MSXCR_UM RT_BIT(11)
+%define X86_MSXCR_PM RT_BIT(12)
+%define X86_MSXCR_RC_MASK 0x6000
+%define X86_MSXCR_RC_NEAREST 0x0000
+%define X86_MSXCR_RC_DOWN 0x2000
+%define X86_MSXCR_RC_UP 0x4000
+%define X86_MSXCR_RC_ZERO 0x6000
+%define X86_MSXCR_FZ RT_BIT(15)
+%define X86_MSXCR_MM RT_BIT(16)
%ifndef VBOX_FOR_DTRACE_LIB
%endif
+%define X86DESCATTR_TYPE 0x0000000f
+%define X86DESCATTR_DT 0x00000010
+%define X86DESCATTR_DPL 0x00000060
+%define X86DESCATTR_DPL_SHIFT 5
+%define X86DESCATTR_P 0x00000080
+%define X86DESCATTR_LIMIT_HIGH 0x00000f00
+%define X86DESCATTR_AVL 0x00001000
+%define X86DESCATTR_L 0x00002000
+%define X86DESCATTR_D 0x00004000
+%define X86DESCATTR_G 0x00008000
+%define X86DESCATTR_UNUSABLE 0x00010000
%ifndef VBOX_FOR_DTRACE_LIB
%endif
%ifndef VBOX_FOR_DTRACE_LIB
@@ -645,6 +727,7 @@
%define X86_SEL_LDT 0x0004
%define X86_SEL_RPL 0x0003
%define X86_SEL_RPL_LDT 0x0007
+%define X86_XCPT_MAX (X86_XCPT_SX)
%define X86_TRAP_ERR_EXTERNAL 1
%define X86_TRAP_ERR_IDT 2
%define X86_TRAP_ERR_TI 4
@@ -702,5 +785,20 @@
%define X86_SREG_FS 4
%define X86_SREG_GS 5
%define X86_SREG_COUNT 6
+%define X86_OP_PRF_CS 0x2e
+%define X86_OP_PRF_SS 0x36
+%define X86_OP_PRF_DS 0x3e
+%define X86_OP_PRF_ES 0x26
+%define X86_OP_PRF_FS 0x64
+%define X86_OP_PRF_GS 0x65
+%define X86_OP_PRF_SIZE_OP 0x66
+%define X86_OP_PRF_SIZE_ADDR 0x67
+%define X86_OP_PRF_LOCK 0xf0
+%define X86_OP_PRF_REPZ 0xf2
+%define X86_OP_PRF_REPNZ 0xf3
+%define X86_OP_REX_B 0x41
+%define X86_OP_REX_X 0x42
+%define X86_OP_REX_R 0x44
+%define X86_OP_REX_W 0x48
%endif
%include "iprt/x86extra.mac"
diff --git a/include/iprt/x86extra.mac b/include/iprt/x86extra.mac
index f705984c..edae0dc6 100644
--- a/include/iprt/x86extra.mac
+++ b/include/iprt/x86extra.mac
@@ -4,7 +4,7 @@
;
;
-; Copyright (C) 2012 Oracle Corporation
+; Copyright (C) 2012-2013 Oracle Corporation
;
; This file is part of VirtualBox Open Source Edition (OSE), as
; available from http://www.virtualbox.org. This file is free software;
@@ -28,12 +28,29 @@
%define ___iprt_x86extra_mac
-%define X86_XCPT_UD 6
-%define X86_XCPT_GP 13
-%define X86_XCPT_PF 14
-%define X86_XCPT_MF 16
+%define X86_XCPT_DE 0x00
+%define X86_XCPT_DB 0x01
+%define X86_XCPT_NMI 0x02
+%define X86_XCPT_BP 0x03
+%define X86_XCPT_OF 0x04
+%define X86_XCPT_BR 0x05
+%define X86_XCPT_UD 0x06
+%define X86_XCPT_NM 0x07
+%define X86_XCPT_DF 0x08
+%define X86_XCPT_CO_SEG_OVERRUN 0x09
+%define X86_XCPT_TS 0x0a
+%define X86_XCPT_NP 0x0b
+%define X86_XCPT_SS 0x0c
+%define X86_XCPT_GP 0x0d
+%define X86_XCPT_PF 0x0e
+%define X86_XCPT_MF 0x10
+%define X86_XCPT_AC 0x11
+%define X86_XCPT_MC 0x12
+%define X86_XCPT_XF 0x13
+%define X86_XCPT_VE 0x14
+%define X86_XCPT_SX 0x1f
-%define PAGE_SIZE 0x1000
+%define PAGE_SIZE 0x1000
;;
@@ -99,5 +116,94 @@ struc X86FXSTATE
endstruc
+struc X86TSS16
+ .selPrev resw 1
+ .sp0 resw 1
+ .ss0 resw 1
+ .sp1 resw 1
+ .ss1 resw 1
+ .sp2 resw 1
+ .ss2 resw 1
+ .ip resw 1
+ .flags resw 1
+ .ax resw 1
+ .cx resw 1
+ .dx resw 1
+ .bx resw 1
+ .sp resw 1
+ .bp resw 1
+ .si resw 1
+ .di resw 1
+ .es resw 1
+ .cs resw 1
+ .ss resw 1
+ .ds resw 1
+ .selLdt resw 1
+endstruc
+AssertCompileSize(X86TSS16, 44)
+
+
+struc X86TSS32
+ .selPrev resw 1
+ .padding1 resw 1
+ .esp0 resd 1
+ .ss0 resw 1
+ .padding_ss0 resw 1
+ .esp1 resd 1
+ .ss1 resw 1
+ .padding_ss1 resw 1
+ .esp2 resd 1
+ .ss2 resw 1
+ .padding_ss2 resw 1
+ .cr3 resd 1
+ .eip resd 1
+ .eflags resd 1
+ .eax resd 1
+ .ecx resd 1
+ .edx resd 1
+ .ebx resd 1
+ .esp resd 1
+ .ebp resd 1
+ .esi resd 1
+ .edi resd 1
+ .es resw 1
+ .padding_es resw 1
+ .cs resw 1
+ .padding_cs resw 1
+ .ss resw 1
+ .padding_ss resw 1
+ .ds resw 1
+ .padding_ds resw 1
+ .fs resw 1
+ .padding_fs resw 1
+ .gs resw 1
+ .padding_gs resw 1
+ .selLdt resw 1
+ .padding_ldt resw 1
+ .fDebugTrap resw 1
+ .offIoBitmap resw 1
+ .IntRedirBitmap resb 32
+endstruc
+
+
+struc X86TSS64
+ .u32Reserved resd 1
+ .rsp0 resq 1
+ .rsp1 resq 1
+ .rsp2 resq 1
+ .u32Reserved2 resd 2
+ .ist1 resq 1
+ .ist2 resq 1
+ .ist3 resq 1
+ .ist4 resq 1
+ .ist5 resq 1
+ .ist6 resq 1
+ .ist7 resq 1
+ .u16Reserved resw 5
+ .offIoBitmap resw 1
+ .IntRedirBitmap resb 32
+endstruc
+AssertCompileSize(X86TSS64, 136)
+
%endif
diff --git a/include/iprt/zip.h b/include/iprt/zip.h
index f3bfd4bd..83ab92f7 100644
--- a/include/iprt/zip.h
+++ b/include/iprt/zip.h
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-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;
@@ -29,7 +29,6 @@
#include <iprt/cdefs.h>
#include <iprt/types.h>
-
RT_C_DECLS_BEGIN
/** @defgroup grp_rt_zip RTZip - Compression
@@ -221,13 +220,36 @@ RTDECL(int) RTZipBlockDecompress(RTZIPTYPE enmType, uint32_t fFlags,
*
* @returns IPRT status code.
*
- * @param hVfsIosIn The compressed input stream. The reference is
- * not consumed, instead another one is retained.
+ * @param hVfsIosIn The compressed input stream (must be readable).
+ * The reference is not consumed, instead another
+ * one is retained.
* @param fFlags Flags, MBZ.
- * @param phVfsIosOut Where to return the handle to the gzip I/O
- * stream.
+ * @param phVfsIosGunzip Where to return the handle to the gunzipped I/O
+ * stream (read).
+ */
+RTDECL(int) RTZipGzipDecompressIoStream(RTVFSIOSTREAM hVfsIosIn, uint32_t fFlags, PRTVFSIOSTREAM phVfsIosGunzip);
+
+/** @name RTZipGzipDecompressIoStream flags.
+ * @{ */
+/** Allow the smaller ZLIB header as well as the regular GZIP header. */
+#define RTZIPGZIPDECOMP_F_ALLOW_ZLIB_HDR RT_BIT(0)
+/** @} */
+
+
+/**
+ * Opens a gzip decompression I/O stream.
+ *
+ * @returns IPRT status code.
+ *
+ * @param hVfsIosDst The compressed output stream (must be writable).
+ * The reference is not consumed, instead another
+ * one is retained.
+ * @param fFlags Flags, MBZ.
+ * @param uLevel The gzip compression level, 1 thru 9.
+ * @param phVfsIosGzip Where to return the gzip input I/O stream handle
+ * (you write to this).
*/
-RTDECL(int) RTZipGzipDecompressIoStream(RTVFSIOSTREAM hVfsIosIn, uint32_t fFlags, PRTVFSIOSTREAM phVfsIosOut);
+RTDECL(int) RTZipGzipCompressIoStream(RTVFSIOSTREAM hVfsIosDst, uint32_t fFlags, uint8_t uLevel, PRTVFSIOSTREAM phVfsIosGzip);
/**
* Opens a TAR filesystem stream.
@@ -255,6 +277,21 @@ RTDECL(int) RTZipTarFsStreamFromIoStream(RTVFSIOSTREAM hVfsIosIn, uint32_t fFlag
*/
RTDECL(RTEXITCODE) RTZipTarCmd(unsigned cArgs, char **papszArgs);
+/**
+ * Opens a XAR filesystem stream.
+ *
+ * This is used to extract, list or check a XAR archive.
+ *
+ * @returns IPRT status code.
+ *
+ * @param hVfsIosIn The compressed input stream. The reference is
+ * not consumed, instead another one is retained.
+ * @param fFlags Flags, MBZ.
+ * @param phVfsFss Where to return the handle to the XAR filesystem
+ * stream.
+ */
+RTDECL(int) RTZipXarFsStreamFromIoStream(RTVFSIOSTREAM hVfsIosIn, uint32_t fFlags, PRTVFSFSSTREAM phVfsFss);
+
/** @} */
RT_C_DECLS_END