summaryrefslogtreecommitdiff
path: root/stdlib/snprintf.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2016-03-08 12:14:55 -0800
committerH. Peter Anvin <hpa@zytor.com>2016-03-08 12:20:02 -0800
commit3ef4f00d5a14000b91851f4c5e4ca5e701550528 (patch)
tree1b13efa1992915f017c7e3437e19015ba74ad3b6 /stdlib/snprintf.c
parent7ab5595347d70ec9da736a0cedc9675a63356da3 (diff)
downloadnasm-3ef4f00d5a14000b91851f4c5e4ca5e701550528.tar.gz
lib: split library into stdlib and nasmlib; header handling fixes
Split lib/ into nasmlib/ (for nasm-specific functions) and stdlib/ (for replacements for C library functions which may be missing.) Rename the ersatz inttypes.h to nasmint.h so we can use a simple test in compiler.h instead of dealing with include path magic. Remove tests in configure.in for ancient missing functions (which will break the build anyway.) Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'stdlib/snprintf.c')
-rw-r--r--stdlib/snprintf.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/stdlib/snprintf.c b/stdlib/snprintf.c
new file mode 100644
index 00000000..95bfc314
--- /dev/null
+++ b/stdlib/snprintf.c
@@ -0,0 +1,29 @@
+/*
+ * snprintf()
+ *
+ * Implement snprintf() in terms of vsnprintf()
+ */
+
+#include "compiler.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "nasmlib.h"
+
+#if !defined(HAVE_SNPRINTF) && !defined(HAVE__SNPRINTF)
+
+int snprintf(char *str, size_t size, const char *format, ...)
+{
+ va_list ap;
+ int rv;
+
+ va_start(ap, format);
+ rv = vsnprintf(str, size, format, ap);
+ va_end(ap);
+
+ return rv;
+}
+
+#endif