Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/VBoxDTrace/Makefile.kmk
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/VBoxDTrace/Makefile.kmk	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/VBoxDTrace/Makefile.kmk	(revision 53655)
@@ -45,18 +45,4 @@
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_aggregate.c \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_buf.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_error.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_list.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_open.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_options.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_proc.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_printf.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_regset.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_string.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_strtab.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_subr.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_work.c \
-	\
-
-VBoxDTrace_VBOX_TODO = \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_cc.c \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_cg.c \
@@ -65,20 +51,36 @@
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_dis.c \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_dof.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_error.c \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_handle.c \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_ident.c \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_inttab.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_link.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_program.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_list.c \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_map.c \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_module.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_names.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_program.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_open.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_options.c \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_parser.c \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_pcb.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_pragma.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_printf.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_proc.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_provider.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_regset.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_string.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_strtab.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_subr.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_work.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_xlator.c \
+
+VBoxDTrace_VBOX_TODO = \
 	$(VBOXDT_PATH_LIBDTRACE)/common/dt_pid.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_pragma.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_provider.c \
-	$(VBOXDT_PATH_LIBDTRACE)/common/dt_xlator.c \
-	\
-	generated: $(VBOXDT_PATH_LIBDTRACE)/common/dt_errtags.c \
+
+# TODO generate these(?): \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_errtags.c \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_names.c \
+
+# Not used: \
+	$(VBOXDT_PATH_LIBDTRACE)/common/dt_link.c \
 
 if 1
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceTypes.h
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceTypes.h	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceTypes.h	(revision 53655)
@@ -47,4 +47,5 @@
 typedef unsigned int                uint_t;
 typedef uintptr_t                   ulong_t;
+typedef int64_t                     longlong_t;
 typedef uint64_t                    u_longlong_t;
 typedef uint64_t                    hrtime_t;
@@ -64,13 +65,16 @@
 #define MICROSEC                    RT_US_1SEC
 #define MILLISEC                    RT_MS_1SEC
-#define SEC                         1
+#define SEC                         (1)
 #define MAXPATHLEN                  RTPATH_MAX
 #define PATH_MAX                    RTPATH_MAX
-#define NBBY                        8
+#define NBBY                        (8)
 #define NCPU                        RTCPUSET_MAX_CPUS
-
+#define B_FALSE                     (0)
+#define B_TRUE                      (1)
 #define MIN(a1, a2)                 RT_MIN(a1, a2)
 #define MAX(a1, a2)                 RT_MAX(a1, a2)
 #define ABS(a_iValue)               RT_ABS(a_iValue)
+#define IS_P2ALIGNED(uWhat, uAlign) ( !((uWhat) & ((uAlign) - 1)) )
+#define P2ROUNDUP(uWhat, uAlign)    ( ((uWhat) + (uAlign) - 1) & ~(uAlign - 1) )
 #define	roundup(uWhat, uUnit)	    ( ( (uWhat) + ((uUnit) - 1)) / (uUnit) * (uUnit) )
 
@@ -176,9 +180,4 @@
  * Kernel stuff...
  */
-#define P2ROUNDUP(uWhat, uAlign)    ( ((uWhat) + (uAlign) - 1) & ~(uAlign - 1) )
-#define IS_P2ALIGNED(uWhat, uAlign) ( !((uWhat) & ((uAlign) - 1)) )
-
-#define B_FALSE                     (0)
-#define B_TRUE                      (1)
 #define CPU_ON_INTR(a_pCpu)         (false)
 
@@ -417,4 +416,11 @@
 # define strlcpy(a_pszDst, a_pszSrc, a_cbDst) ((void)RTStrCopy(a_pszDst, a_cbDst, a_pszSrc))
 
+/* Replacement for strndup(), requires editing the code unfortunately. */
+# define MY_STRDUPA(a_pszRes, a_pszSrc) \
+	do { \
+		size_t cb = strlen(a_pszSrc) + 1; \
+		(a_pszRes) = (char *)alloca(cb); \
+		memcpy(a_pszRes, a_pszSrc, cb); \
+	} while (0)
 
 #endif
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cc.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cc.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cc.c	(revision 53655)
@@ -81,4 +81,5 @@
  */
 
+#ifndef VBOX
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -95,4 +96,15 @@
 #include <ctype.h>
 #include <dirent.h>
+#else  /* VBOX */
+# include <ctype.h>
+# include <iprt/dir.h>
+# ifdef _MSC_VER
+#  include <io.h>
+#  define ftruncate64   _chsize
+#  define lseek64       lseek
+# else
+#  include <unistd.h>
+# endif
+#endif /* VBOX */
 #include <dt_module.h>
 #include <dt_program.h>
@@ -1429,9 +1441,12 @@
 	const dtrace_pattr_t *pap;
 	dt_probe_t *prp;
+#ifndef VBOX
 	dt_provider_t *pvp;
+#endif
 	dt_ident_t *idp;
 	char attrstr[8];
 	int err;
 
+#ifndef VBOX
 	/*
 	 * Both kernel and pid based providers are allowed to have names
@@ -1452,4 +1467,5 @@
 		longjmp(yypcb->pcb_jmpbuf, EDT_COMPILER);
 	}
+#endif
 
 	/*
@@ -1583,4 +1599,5 @@
 dt_preproc(dtrace_hdl_t *dtp, FILE *ifp)
 {
+#ifndef VBOX
 	int argc = dtp->dt_cpp_argc;
 	char **argv = malloc(sizeof (char *) * (argc + 5));
@@ -1707,4 +1724,8 @@
 	(void) fclose(ofp);
 	return (NULL);
+#else  /* VBOX */
+	(void) dt_set_errno(dtp, EDT_CPPERR);
+	return (NULL);
+#endif /* VBOX */
 }
 
@@ -1927,7 +1948,14 @@
 dt_load_libs_dir(dtrace_hdl_t *dtp, const char *path)
 {
+#ifndef VBOX
 	struct dirent *dp;
 	const char *p;
 	DIR *dirp;
+#else
+	PRTDIR pDir;
+	RTDIRENTRY DirEntry;
+	const char *p;
+	int rc;
+#endif
 
 	char fname[PATH_MAX];
@@ -1937,11 +1965,26 @@
 	dt_lib_depend_t *dld;
 
+#ifndef VBOX
 	if ((dirp = opendir(path)) == NULL) {
 		dt_dprintf("skipping lib dir %s: %s\n", path, strerror(errno));
 		return (0);
 	}
+#else
+	rc = RTDirOpen(&pDir, path);
+	if (RT_FAILURE(rc)) {
+		dt_dprintf("skipping lib dir %s: %s\n", path, RTErrGetShort(rc));
+		return (0);
+	}
+#endif
 
 	/* First, parse each file for library dependencies. */
+#ifndef VBOX
 	while ((dp = readdir(dirp)) != NULL) {
+#else
+	while (RT_SUCCESS(RTDirRead(pDir, &DirEntry, 0))) {
+		struct FakeDirEntry {
+			const char *d_name;
+		} FakeDirEntry = { DirEntry.szName }, *dp = &FakeDirEntry;
+#endif
 		if ((p = strrchr(dp->d_name, '.')) == NULL || strcmp(p, ".d"))
 			continue; /* skip any filename not ending in .d */
@@ -1977,5 +2020,9 @@
 	}
 
+#ifndef VBOX
 	(void) closedir(dirp);
+#else
+	RTDirClose(pDir);
+#endif
 	/*
 	 * Finish building the graph containing the library dependencies
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cg.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cg.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_cg.c	(revision 53655)
@@ -478,5 +478,10 @@
 
 	dif_instr_t instr;
+#ifndef VBOX
 	int reg, n;
+#else
+	int reg;
+	uint64_t n;
+#endif
 
 	if (dt_node_is_scalar(dst) && (dstsize < srcsize ||
@@ -522,5 +527,5 @@
 	const dt_idsig_t *isp = idp->di_data;
 	dt_node_t *dnp;
-	int i = 0;
+	VBDTTYPE(uint_t,int) i = 0;
 
 	for (dnp = args; dnp != NULL; dnp = dnp->dn_list)
@@ -1218,5 +1223,10 @@
 	uint_t op;
 	size_t size;
+#ifndef VBOX
 	int reg, n;
+#else
+	int reg;
+	uint64_t n;
+#endif
 
 	assert(dnp->dn_kind == DT_NODE_VAR);
@@ -1860,11 +1870,14 @@
 			dtrace_hdl_t *dtp = yypcb->pcb_hdl;
 			dtrace_syminfo_t *sip = dnp->dn_ident->di_data;
+#ifndef VBOX
 			GElf_Sym sym;
 
 			if (dtrace_lookup_by_name(dtp,
 			    sip->dts_object, sip->dts_name, &sym, NULL) == -1) {
+#endif
 				xyerror(D_UNKNOWN, "cg failed for symbol %s`%s:"
 				    " %s\n", sip->dts_object, sip->dts_name,
 				    dtrace_errmsg(dtp, dtrace_errno(dtp)));
+#ifndef VBOX
 			}
 
@@ -1881,4 +1894,5 @@
 				    dt_cg_node_alloc(DT_LBL_NONE, instr));
 			}
+#endif
 			break;
 		}
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_consume.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_consume.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_consume.c	(revision 53655)
@@ -24,4 +24,5 @@
  */
 
+#ifndef VBOX
 #include <stdlib.h>
 #include <strings.h>
@@ -32,4 +33,16 @@
 #include <ctype.h>
 #include <alloca.h>
+#else  /* VBOX */
+# include <ctype.h>
+# include <iprt/mp.h>
+# ifdef _MSC_VER
+#  pragma warning(disable:4146) /* -uint64_t warnings */
+#  include <io.h>
+#  define ftruncate 	_chsize
+#  define fseeko		fseek
+# else
+#  include <unistd.h>
+# endif
+#endif /* VBOX */
 #include <dt_impl.h>
 
@@ -385,5 +398,5 @@
 	static const char *r_str[2] = { " <- ", " <= " };
 	static const char *ent = "entry", *ret = "return";
-	static int entlen = 0, retlen = 0;
+	static VBDTTYPE(size_t,int) entlen = 0, retlen = 0;
 	dtrace_epid_t next, id = epd->dtepd_epid;
 	int rval;
@@ -824,6 +837,8 @@
     caddr_t addr, int depth, int size)
 {
+#ifndef VBOX
 	dtrace_syminfo_t dts;
 	GElf_Sym sym;
+#endif
 	int i, indent;
 	char c[PATH_MAX * 2];
@@ -857,5 +872,5 @@
 		}
 
-		if (pc == NULL)
+		if (pc == 0 /*VBOX: NULL is a ptr */)
 			break;
 
@@ -865,4 +880,5 @@
 			return (-1);
 
+#ifndef VBOX
 		if (dtrace_lookup_by_addr(dtp, pc, &sym, &dts) == 0) {
 			if (pc > sym.st_value) {
@@ -884,7 +900,10 @@
 				    dts.dts_object, pc);
 			} else {
+#endif
 				(void) snprintf(c, sizeof (c), "0x%llx", pc);
+#ifndef VBOX
 			}
 		}
+#endif
 
 		if (dt_printf(dtp, fp, format, c) < 0)
@@ -910,7 +929,11 @@
 	int err = 0;
 
+#ifndef VBOX
 	char name[PATH_MAX], objname[PATH_MAX], c[PATH_MAX * 2];
 	struct ps_prochandle *P;
 	GElf_Sym sym;
+#else
+	char c[PATH_MAX * 2];
+#endif
 	int i, indent;
 	pid_t pid;
@@ -937,4 +960,5 @@
 	 * this is a vector open, we just print the raw address or string.
 	 */
+#ifndef VBOX
 	if (dtp->dt_vector == NULL)
 		P = dt_proc_grab(dtp, pid, PGRAB_RDONLY | PGRAB_FORCE, 0);
@@ -944,11 +968,15 @@
 	if (P != NULL)
 		dt_proc_lock(dtp, P); /* lock handle while we perform lookups */
-
-	for (i = 0; i < depth && pc[i] != NULL; i++) {
+#endif
+
+	for (i = 0; VBDTCAST(uint_t)i < depth && pc[i] != 0/*NULL*/; i++) {
+#ifndef VBOX
 		const prmap_t *map;
+#endif
 
 		if ((err = dt_printf(dtp, fp, "%*s", indent, "")) < 0)
 			break;
 
+#ifndef VBOX
 		if (P != NULL && Plookup_by_addr(P, pc[i],
 		    name, sizeof (name), &sym) == 0) {
@@ -986,4 +1014,7 @@
 				    dt_basename(objname), (u_longlong_t)pc[i]);
 			} else {
+#else
+		{	{
+#endif
 				(void) snprintf(c, sizeof (c), "0x%llx",
 				    (u_longlong_t)pc[i]);
@@ -1023,8 +1054,10 @@
 	}
 
+#ifndef VBOX
 	if (P != NULL) {
 		dt_proc_unlock(dtp, P);
 		dt_proc_release(dtp, P);
 	}
+#endif
 
 	return (err);
@@ -1042,4 +1075,5 @@
 	int n, len = 256;
 
+#ifndef VBOX
 	if (act == DTRACEACT_USYM && dtp->dt_vector == NULL) {
 		struct ps_prochandle *P;
@@ -1058,4 +1092,5 @@
 		}
 	}
+#endif
 
 	do {
@@ -1076,10 +1111,15 @@
 	int err = 0;
 
+#ifndef VBOX
 	char objname[PATH_MAX], c[PATH_MAX * 2];
 	struct ps_prochandle *P;
+#else
+	char c[64];
+#endif
 
 	if (format == NULL)
 		format = "  %-50s";
 
+#ifndef VBOX
 	/*
 	 * See the comment in dt_print_ustack() for the rationale for
@@ -1106,4 +1146,8 @@
 		dt_proc_release(dtp, P);
 	}
+#else  /* VBOX */
+	snprintf(c, sizeof (c), "0x%llx", (u_longlong_t)pc);
+	err = dt_printf(dtp, fp, format, c);
+#endif /* VBOX */
 
 	return (err);
@@ -1115,11 +1159,16 @@
 	/* LINTED - alignment */
 	uint64_t pc = *((uint64_t *)addr);
+#ifndef VBOX
 	dtrace_syminfo_t dts;
 	GElf_Sym sym;
 	char c[PATH_MAX * 2];
+#else
+	char c[64];
+#endif
 
 	if (format == NULL)
 		format = "  %-50s";
 
+#ifndef VBOX
 	if (dtrace_lookup_by_addr(dtp, pc, &sym, &dts) == 0) {
 		(void) snprintf(c, sizeof (c), "%s`%s",
@@ -1139,4 +1188,7 @@
 		}
 	}
+#else
+	snprintf(c, sizeof (c), "0x%llx", (u_longlong_t)pc);
+#endif
 
 	if (dt_printf(dtp, fp, format, c) < 0)
@@ -1151,5 +1203,7 @@
 	/* LINTED - alignment */
 	uint64_t pc = *((uint64_t *)addr);
+#ifndef VBOX
 	dtrace_syminfo_t dts;
+#endif
 	char c[PATH_MAX * 2];
 
@@ -1157,7 +1211,10 @@
 		format = "  %-50s";
 
+#ifndef VBOX
 	if (dtrace_lookup_by_addr(dtp, pc, NULL, &dts) == 0) {
 		(void) snprintf(c, sizeof (c), "%s", dts.dts_object);
-	} else {
+	} else
+#endif
+	{
 		(void) snprintf(c, sizeof (c), "0x%llx", (u_longlong_t)pc);
 	}
@@ -1541,5 +1598,10 @@
     const char *option, const char *value)
 {
+#ifndef VBOX
 	int len, rval;
+#else
+	size_t len;
+	int rval;
+#endif
 	char *msg;
 	const char *errstr;
@@ -2123,5 +2185,9 @@
 
 	if (max_ncpus == 0)
+#ifndef VBOX
 		max_ncpus = dt_sysconf(dtp, _SC_CPUID_MAX) + 1;
+#else
+		max_ncpus = RTMpGetMaxCpuId() + 1;
+#endif
 
 	for (i = 0; i < max_ncpus; i++) {
@@ -2189,5 +2255,5 @@
 
 	if (dtp->dt_lastswitch != 0) {
-		if (now - dtp->dt_lastswitch < interval)
+		if (now - dtp->dt_lastswitch < VBDTCAST(hrtime_t)interval)
 			return (0);
 
@@ -2201,5 +2267,9 @@
 
 	if (max_ncpus == 0)
+#ifndef VBOX
 		max_ncpus = dt_sysconf(dtp, _SC_CPUID_MAX) + 1;
+#else
+		max_ncpus = RTMpGetMaxCpuId() + 1;
+#endif
 
 	if (pf == NULL)
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_decl.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_decl.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_decl.c	(revision 53655)
@@ -24,4 +24,5 @@
  */
 
+#ifndef VBOX
 #include <strings.h>
 #include <stdlib.h>
@@ -29,4 +30,5 @@
 #include <alloca.h>
 #include <assert.h>
+#endif
 
 #include <dt_decl.h>
@@ -701,5 +703,9 @@
 	int value;
 
+#ifndef VBOX
 	name = strdupa(s);
+#else
+	MY_STRDUPA(name, s);
+#endif
 	free(s);
 
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dis.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dis.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dis.c	(revision 53655)
@@ -25,8 +25,10 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
 #include <strings.h>
 #include <stdio.h>
+#endif
 
 #include <dt_impl.h>
@@ -120,5 +122,5 @@
 	case 't': return (DIFV_SCOPE_THREAD);
 	case 'g': return (DIFV_SCOPE_GLOBAL);
-	default: return (-1u);
+	default: return (~0u /*VBOX: was -1u*/);
 	}
 }
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dof.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dof.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_dof.c	(revision 53655)
@@ -24,4 +24,5 @@
  */
 
+#ifndef VBOX
 #include <sys/types.h>
 #include <sys/sysmacros.h>
@@ -33,4 +34,7 @@
 #include <errno.h>
 #include <limits.h>
+#else  /* VBOX */
+# include <iprt/asm.h>
+#endif /* VBOX */
 
 #include <dt_impl.h>
@@ -191,5 +195,5 @@
 {
 	dt_buf_t *bp = &ddo->ddo_strs;
-	dof_stridx_t i = dt_buf_len(bp);
+	dof_stridx_t i = VBDTCAST(dof_stridx_t)dt_buf_len(bp);
 
 	if (i != 0 && (s == NULL || *s == '\0'))
@@ -406,5 +410,5 @@
 	dofpr.dofpr_addr = 0;
 	dofpr.dofpr_name = dof_add_string(ddo, prp->pr_name);
-	dofpr.dofpr_nargv = dt_buf_len(&ddo->ddo_strs);
+	dofpr.dofpr_nargv = VBDTCAST(dof_stridx_t)dt_buf_len(&ddo->ddo_strs);
 
 	for (dnp = prp->pr_nargs; dnp != NULL; dnp = dnp->dn_list) {
@@ -413,5 +417,5 @@
 	}
 
-	dofpr.dofpr_xargv = dt_buf_len(&ddo->ddo_strs);
+	dofpr.dofpr_xargv = VBDTCAST(dof_stridx_t)dt_buf_len(&ddo->ddo_strs);
 
 	for (dnp = prp->pr_xargs; dnp != NULL; dnp = dnp->dn_list) {
@@ -420,5 +424,5 @@
 	}
 
-	dofpr.dofpr_argidx = dt_buf_len(&ddo->ddo_args) / sizeof (uint8_t);
+	dofpr.dofpr_argidx = VBDTCAST(uint32_t)dt_buf_len(&ddo->ddo_args) / sizeof (uint8_t);
 
 	for (i = 0; i < prp->pr_xargc; i++) {
@@ -446,5 +450,5 @@
 
 		dofpr.dofpr_offidx =
-		    dt_buf_len(&ddo->ddo_offs) / sizeof (uint32_t);
+		    VBDTCAST(uint32_t)(dt_buf_len(&ddo->ddo_offs) / sizeof (uint32_t));
 		dofpr.dofpr_noffs = pip->pi_noffs;
 		dt_buf_write(dtp, &ddo->ddo_offs, pip->pi_offs,
@@ -452,5 +456,5 @@
 
 		dofpr.dofpr_enoffidx =
-		    dt_buf_len(&ddo->ddo_enoffs) / sizeof (uint32_t);
+		    VBDTCAST(uint32_t)(dt_buf_len(&ddo->ddo_enoffs) / sizeof (uint32_t));
 		dofpr.dofpr_nenoffs = pip->pi_nenoffs;
 		dt_buf_write(dtp, &ddo->ddo_enoffs, pip->pi_enoffs,
@@ -663,5 +667,5 @@
 
 		if (sdp->dtsd_fmtdata != NULL) {
-			i = dtrace_printf_format(dtp,
+			i = VBDTCAST(uint_t)dtrace_printf_format(dtp,
 			    sdp->dtsd_fmtdata, NULL, 0);
 			maxfmt = MAX(maxfmt, i);
@@ -822,6 +826,8 @@
 		(void) dof_add_usect(ddo, _dtrace_version, DOF_SECT_COMMENTS,
 		    sizeof (char), 0, 0, strlen(_dtrace_version) + 1);
+#ifndef VBOX
 		(void) dof_add_usect(ddo, &dtp->dt_uts, DOF_SECT_UTSNAME,
 		    sizeof (char), 0, 0, sizeof (struct utsname));
+#endif
 	}
 
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_handle.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_handle.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_handle.c	(revision 53655)
@@ -24,4 +24,5 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
@@ -33,4 +34,5 @@
 #include <assert.h>
 #include <alloca.h>
+#endif
 
 #include <dt_impl.h>
@@ -157,5 +159,5 @@
 	const char *faultstr;
 	char *str;
-	int len;
+	VBDTTYPE(size_t,int) len;
 
 	assert(epd->dtepd_uarg == DT_ECB_ERROR);
@@ -240,5 +242,5 @@
 	const int slop = 80;
 	char *str;
-	int len;
+	VBDTTYPE(size_t,int) len;
 
 	err.dteda_edesc = data->dtpda_edesc;
@@ -248,5 +250,5 @@
 	err.dteda_offset = -1;
 	err.dteda_fault = DTRACEFLT_LIBRARY;
-	err.dteda_addr = NULL;
+	err.dteda_addr = 0 /*NULL*/;
 
 	len = strlen(faultstr) +
@@ -313,5 +315,5 @@
 	dtrace_dropdata_t drop;
 	char str[80], *s;
-	int size;
+	VBDTTYPE(size_t,int) size;
 
 	assert(what == DTRACEDROP_PRINCIPAL || what == DTRACEDROP_AGGREGATION);
@@ -420,5 +422,5 @@
 			    dt_droptag(_dt_droptab[i].dtdrt_kind));
 			s = &str[strlen(str)];
-			size = sizeof (str) - (s - str);
+			size = VBDTCAST(int)sizeof (str) - (s - str);
 		} else {
 			s = str;
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_ident.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_ident.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_ident.c	(revision 53655)
@@ -24,4 +24,5 @@
  */
 
+#ifndef VBOX
 #include <sys/sysmacros.h>
 #include <strings.h>
@@ -33,4 +34,7 @@
 #include <sys/procfs_isa.h>
 #include <limits.h>
+#else  /* VBOX */
+# include <ctype.h>
+#endif /* VBOX */
 
 #include <dt_ident.h>
@@ -179,5 +183,9 @@
 
 		assert(idp->di_iarg != NULL);
+#ifndef VBOX
 		s = strdupa(idp->di_iarg);
+#else
+		MY_STRDUPA(s, idp->di_iarg);
+#endif
 
 		if ((p2 = strrchr(s, ')')) != NULL)
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_inttab.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_inttab.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_inttab.c	(revision 53655)
@@ -25,7 +25,9 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
 #include <assert.h>
+#endif
 
 #include <dt_inttab.h>
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_map.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_map.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_map.c	(revision 53655)
@@ -24,4 +24,5 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
@@ -31,4 +32,5 @@
 #include <unistd.h>
 #include <assert.h>
+#endif
 
 #include <dt_impl.h>
@@ -43,5 +45,5 @@
 	dtrace_probedesc_t *probe;
 
-	while (id >= (max = dtp->dt_maxprobe) || dtp->dt_pdesc == NULL) {
+	while (id >= (max = VBDTCAST(dtrace_id_t)dtp->dt_maxprobe) || dtp->dt_pdesc == NULL) {
 		dtrace_id_t new_max = max ? (max << 1) : 1;
 		size_t nsize = new_max * sizeof (void *);
@@ -293,5 +295,5 @@
 	int rval;
 
-	while (id >= (max = dtp->dt_maxagg) || dtp->dt_aggdesc == NULL) {
+	while (id >= (max = VBDTCAST(dtrace_id_t)dtp->dt_maxagg) || dtp->dt_aggdesc == NULL) {
 		dtrace_id_t new_max = max ? (max << 1) : 1;
 		size_t nsize = new_max * sizeof (void *);
@@ -360,5 +362,5 @@
 		 */
 		if (dtp->dt_options[DTRACEOPT_GRABANON] == DTRACEOPT_UNSET &&
-		    agg->dtagd_rec[0].dtrd_uarg != NULL) {
+		    agg->dtagd_rec[0].dtrd_uarg != 0 /*NULL*/) {
 			dtrace_stmtdesc_t *sdp;
 			dt_ident_t *aid;
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_module.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_module.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_module.c	(revision 53655)
@@ -24,4 +24,5 @@
  */
 
+#ifndef VBOX
 #include <sys/types.h>
 #include <sys/modctl.h>
@@ -41,8 +42,12 @@
 #include <errno.h>
 #include <dirent.h>
+#else  /* VBOX */
+#endif /* VBOX */
 
 #include <dt_strtab.h>
 #include <dt_module.h>
 #include <dt_impl.h>
+
+#ifndef VBOX /** @todo port what is necessary here ! */
 
 static const char *dt_module_strtab; /* active strtab for qsort callbacks */
@@ -1312,2 +1317,4 @@
 	return (0);
 }
+
+#endif /* !VBOX */
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_parser.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_parser.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_parser.c	(revision 53655)
@@ -92,4 +92,5 @@
  */
 
+#ifndef VBOX
 #include <sys/param.h>
 #include <limits.h>
@@ -103,4 +104,11 @@
 #include <errno.h>
 #include <ctype.h>
+#else  /* VBOX */
+# include <ctype.h>
+# ifdef _MSC_VER
+#  pragma warning(disable:4146) /* -unsigned */
+#  pragma warning(disable:4267) /* size_t to int */
+# endif
+#endif /* VBOX */
 
 #include <dt_impl.h>
@@ -761,6 +769,8 @@
 dt_node_sizeof(const dt_node_t *dnp)
 {
+#ifndef VBOX
 	dtrace_syminfo_t *sip;
 	GElf_Sym sym;
+#endif
 	dtrace_hdl_t *dtp = yypcb->pcb_hdl;
 
@@ -777,4 +787,5 @@
 		return (dt_node_type_size(dnp));
 
+#ifndef VBOX
 	sip = dnp->dn_ident->di_data;
 
@@ -784,4 +795,7 @@
 
 	return (sym.st_size);
+#else
+	return (0);
+#endif
 }
 
@@ -1423,4 +1437,5 @@
 
 	case DT_DC_EXTERN: {
+#ifndef VBOX
 		dtrace_typeinfo_t ott;
 		dtrace_syminfo_t dts;
@@ -1445,5 +1460,8 @@
 			    "failed to extern %s: %s\n", dsp->ds_ident,
 			    dtrace_errmsg(dtp, dtrace_errno(dtp)));
-		} else {
+		} else
+#endif
+		{
+
 			dt_dprintf("extern %s`%s type=<%s>\n",
 			    dmp->dm_name, dsp->ds_ident,
@@ -1753,5 +1771,9 @@
 	uint_t kind;
 
+#ifndef VBOX
 	name = strdupa(s);
+#else
+	MY_STRDUPA(name, s);
+#endif
 	free(s);
 
@@ -2570,6 +2592,8 @@
 	dtrace_attribute_t attr = _dtrace_defattr;
 	dt_ident_t *idp;
+#ifndef VBOX
 	dtrace_syminfo_t dts;
 	GElf_Sym sym;
+#endif
 
 	const char *scope, *mark;
@@ -2660,4 +2684,5 @@
 		dt_node_attr_assign(dnp, attr);
 
+#ifndef VBOX
 	} else if (dhp == dtp->dt_globals && scope != DTRACE_OBJ_EXEC &&
 	    dtrace_lookup_by_name(dtp, scope, name, &sym, &dts) == 0) {
@@ -2728,5 +2753,5 @@
 			dnp->dn_flags |= DT_NF_USERLAND;
 		}
-
+#endif /* !VBOX */
 	} else if (scope == DTRACE_OBJ_EXEC && create == B_TRUE) {
 		uint_t flags = DT_IDFLG_WRITE;
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pcb.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pcb.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pcb.c	(revision 53655)
@@ -25,5 +25,7 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
+#endif
 
 /*
@@ -45,7 +47,9 @@
  */
 
+#ifndef VBOX
 #include <strings.h>
 #include <stdlib.h>
 #include <assert.h>
+#endif
 
 #include <dt_impl.h>
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pragma.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pragma.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_pragma.c	(revision 53655)
@@ -24,4 +24,5 @@
  */
 
+#ifndef VBOX
 #include <assert.h>
 #include <strings.h>
@@ -29,4 +30,5 @@
 #include <stdlib.h>
 #include <stdio.h>
+#endif
 
 #include <dt_parser.h>
@@ -335,5 +337,9 @@
 	}
 
+#ifndef VBOX
 	opt = strdupa(dnp->dn_string);
+#else
+	MY_STRDUPA(opt, dnp->dn_string);
+#endif
 
 	if ((val = strchr(opt, '=')) != NULL)
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_program.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_program.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_program.c	(revision 53655)
@@ -24,4 +24,5 @@
  */
 
+#ifndef VBOX
 #include <unistd.h>
 #include <strings.h>
@@ -31,4 +32,7 @@
 #include <ctype.h>
 #include <alloca.h>
+#else
+# include <ctype.h>
+#endif
 
 #include <dt_impl.h>
@@ -455,5 +459,5 @@
 	char *mname, *fname;
 	const char *p;
-	int i;
+	VBDTTYPE(uint_t,int) i;
 
 	p = prp->pr_name;
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_provider.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_provider.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_provider.c	(revision 53655)
@@ -25,4 +25,5 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
@@ -37,4 +38,7 @@
 #include <unistd.h>
 #include <errno.h>
+#else  /* VBOX */
+# include <iprt/asm.h>
+#endif /* VBOX */
 
 #include <dt_provider.h>
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_subr.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_subr.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_subr.c	(revision 53655)
@@ -227,7 +227,4 @@
 	dtrace_class_t c;
 	char *p, *q;
-#ifdef VBOX
-	size_t cbStr;
-#endif
 
 	if (str == NULL || attr == NULL)
@@ -238,7 +235,5 @@
 	p = strdupa(str);
 #else
-	cbStr = strlen(str) + 1;
-	p = alloca(cbStr);
-	memcpy(p, str, cbStr);
+	MY_STRDUPA(p, str);
 #endif
 
Index: /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_xlator.c
===================================================================
--- /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_xlator.c	(revision 53654)
+++ /trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/lib/libdtrace/common/dt_xlator.c	(revision 53655)
@@ -25,8 +25,10 @@
  */
 
+#ifndef VBOX
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
 #include <strings.h>
 #include <assert.h>
+#endif
 
 #include <dt_xlator.h>
