--- old/usr/src/lib/libdisasm/Makefile.com	2014-08-01 15:57:43.672865814 -0400
+++ new/usr/src/lib/libdisasm/Makefile.com	2014-08-01 15:57:43.678462280 -0400
@@ -22,6 +22,7 @@
 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 # Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
+# Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
 #
 
 #
@@ -120,13 +121,7 @@
 # doesn't get it.
 DTS_ERRNO=
 
-# We need to rename some standard functions so we can easily implement them 
-# in consumers.
-STAND_RENAMED_FUNCS= \
-	snprintf
-
-CPPFLAGS_standalone = -DDIS_STANDALONE $(STAND_RENAMED_FUNCS:%=-D%=mdb_%) \
-	-Dvsnprintf=mdb_iob_vsnprintf -I$(SRC)/cmd/mdb/common
+CPPFLAGS_standalone = -DDIS_STANDALONE -I$(SRC)/cmd/mdb/common
 CPPFLAGS_library = -D_REENTRANT
 CPPFLAGS +=	-I$(COMDIR) $(CPPFLAGS_$(CURTYPE))
 
--- old/usr/src/lib/libdisasm/common/dis_i386.c	2014-08-01 15:57:43.845009437 -0400
+++ new/usr/src/lib/libdisasm/common/dis_i386.c	2014-08-01 15:57:43.850611883 -0400
@@ -23,11 +23,10 @@
  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
+ * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #include <libdisasm.h>
-#include <stdlib.h>
-#include <stdio.h>
 
 #include "dis_tables.h"
 #include "libdisasm_impl.h"
@@ -126,7 +125,7 @@
 	if (dhp->dh_flags & DIS_OCTAL)
 		dhx->dhx_dis.d86_flags = DIS_F_OCTAL;
 
-	dhx->dhx_dis.d86_sprintf_func = snprintf;
+	dhx->dhx_dis.d86_sprintf_func = dis_snprintf;
 	dhx->dhx_dis.d86_get_byte = get_byte;
 	dhx->dhx_dis.d86_sym_lookup = do_lookup;
 	dhx->dhx_dis.d86_check_func = check_func;
@@ -173,8 +172,6 @@
 	return (1);
 }
 
-#define	MIN(a, b)	((a) < (b) ? (a) : (b))
-
 /*
  * Return the previous instruction.  On x86, we have no choice except to
  * disassemble everything from the start of the symbol, and stop when we have
--- old/usr/src/lib/libdisasm/common/dis_sparc.c	2014-08-01 15:57:44.013345081 -0400
+++ new/usr/src/lib/libdisasm/common/dis_sparc.c	2014-08-01 15:57:44.018935733 -0400
@@ -277,7 +277,7 @@
 
 error:
 
-	(void) snprintf(buf, buflen,
+	(void) dis_snprintf(buf, buflen,
 	    ((dhp->dh_flags & DIS_OCTAL) != 0) ? "0%011lo" : "0x%08lx",
 	    instr);
 
--- old/usr/src/lib/libdisasm/common/dis_sparc_fmt.c	2014-08-01 15:57:44.183037378 -0400
+++ new/usr/src/lib/libdisasm/common/dis_sparc_fmt.c	2014-08-01 15:57:44.188674019 -0400
@@ -49,8 +49,6 @@
 extern int strncmp(const char *, const char *, size_t);
 extern size_t strlcat(char *, const char *, size_t);
 extern size_t strlcpy(char *, const char *, size_t);
-extern int snprintf(char *, size_t, const char *, ...);
-extern int vsnprintf(char *, size_t, const char *, va_list);
 
 /*
  * This file has the functions that do all the dirty work of outputting the
@@ -863,7 +861,7 @@
 		}
 	}
 
-	(void) snprintf(buf, sizeof (buf), "%s%s%s", name, annul, pred);
+	(void) dis_snprintf(buf, sizeof (buf), "%s%s%s", name, annul, pred);
 	prt_name(dhp, buf, 1);
 
 
@@ -2768,7 +2766,7 @@
 	curlen = strlen(dhx->dhx_buf);
 
 	va_start(ap, fmt);
-	(void) vsnprintf(dhx->dhx_buf + curlen, dhx->dhx_buflen - curlen, fmt,
-	    ap);
+	(void) dis_vsnprintf(dhx->dhx_buf + curlen, dhx->dhx_buflen -
+	    curlen, fmt, ap);
 	va_end(ap);
 }
--- old/usr/src/lib/libdisasm/common/libdisasm.c	2014-08-01 15:57:44.436512777 -0400
+++ new/usr/src/lib/libdisasm/common/libdisasm.c	2014-08-01 15:57:44.442084738 -0400
@@ -23,12 +23,17 @@
  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
+ * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #include <libdisasm.h>
 #include <stdlib.h>
 #ifdef DIS_STANDALONE
 #include <mdb/mdb_modapi.h>
+#define	_MDB
+#include <mdb/mdb_io.h>
+#else
+#include <stdio.h>
 #endif
 
 #include "libdisasm_impl.h"
@@ -214,3 +219,26 @@
 {
 	return (dhp->dh_arch->da_instrlen(dhp, pc));
 }
+
+int
+dis_vsnprintf(char *restrict s, size_t n, const char *restrict format,
+    va_list args)
+{
+#ifdef DIS_STANDALONE
+	return (mdb_iob_vsnprintf(s, n, format, args));
+#else
+	return (vsnprintf(s, n, format, args));
+#endif
+}
+
+int
+dis_snprintf(char *restrict s, size_t n, const char *restrict format, ...)
+{
+	va_list args;
+
+	va_start(args, format);
+	n = dis_vsnprintf(s, n, format, args);
+	va_end(args);
+
+	return (n);
+}
--- old/usr/src/lib/libdisasm/common/libdisasm_impl.h	2014-08-01 15:57:44.602466052 -0400
+++ new/usr/src/lib/libdisasm/common/libdisasm_impl.h	2014-08-01 15:57:44.608096243 -0400
@@ -23,11 +23,15 @@
  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
+ * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
  */
 
 #ifndef	_LIBDISASM_IMPL_H
 #define	_LIBDISASM_IMPL_H
 
+#include <stdarg.h>
+#include <sys/sysmacros.h>
+
 #ifdef	__cplusplus
 extern "C" {
 #endif
@@ -58,6 +62,8 @@
 
 extern void *dis_zalloc(size_t);
 extern void dis_free(void *, size_t);
+extern int dis_vsnprintf(char *restrict, size_t, const char *restrict, va_list);
+extern int dis_snprintf(char *restrict, size_t, const char *restrict, ...);
 
 #ifdef	__cplusplus
 }
--- old/usr/src/lib/libdisasm/common/linktest_stand.c	2014-08-01 15:57:44.762978946 -0400
+++ new/usr/src/lib/libdisasm/common/linktest_stand.c	2014-08-01 15:57:44.768958992 -0400
@@ -24,16 +24,14 @@
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  * This file is used to verify that the standalone's external dependencies
  * haven't changed in a way that'll break things that use it.
  */
 
 void mdb_free(void) {}
-void snprintf(void) {}
-void vsnprintf(void) {}
+void mdb_snprintf(void) {}
+void mdb_iob_vsnprintf(void) {}
 void mdb_zalloc(void) {}
 void strcmp(void) {}
 void strlen(void) {}
