diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-24 16:50:02 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-24 16:50:02 -0700 |
commit | 161ca12649ab8bfaf3ef16129ac2b29e6b199781 (patch) | |
tree | 41aecc0876057757e3daa8143b82c1da762d8c06 /src/library.js | |
parent | d597a4f280914b187a3d01bc6bb11fa3ae53be29 (diff) | |
parent | f19bb6022d09a207d5948e5a417309cc638ab74c (diff) |
Merge pull request #1625 from ngld/dprintf
Implemented dprintf. (Fixes #1250)
Diffstat (limited to 'src/library.js')
-rw-r--r-- | src/library.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/library.js b/src/library.js index 2faa40d7..ca3175d1 100644 --- a/src/library.js +++ b/src/library.js @@ -2901,6 +2901,13 @@ LibraryManager.library = { asprintf: function(s, format, varargs) { return _sprintf(-s, format, varargs); }, + dprintf__deps: ['_formatString', 'write'], + dprintf: function(fd, format, varargs) { + var result = __formatString(format, varargs); + var stack = Runtime.stackSave(); + var ret = _write(fd, allocate(result, 'i8', ALLOC_STACK), result.length); + Runtime.stackRestore(stack); + }, #if TARGET_X86 // va_arg is just like our varargs @@ -2909,6 +2916,7 @@ LibraryManager.library = { vprintf: 'printf', vsprintf: 'sprintf', vasprintf: 'asprintf', + vdprintf: 'dprintf', vscanf: 'scanf', vfscanf: 'fscanf', vsscanf: 'sscanf', @@ -2936,6 +2944,10 @@ LibraryManager.library = { vasprintf: function(s, format, va_arg) { return _asprintf(s, format, {{{ makeGetValue('va_arg', 0, '*') }}}); }, + vdprintf__deps: ['dprintf'], + vdprintf: function (fd, format, va_arg) { + return _dprintf(fd, format, {{{ makeGetValue('va_arg', 0, '*') }}}); + }, vscanf__deps: ['scanf'], vscanf: function(format, va_arg) { return _scanf(format, {{{ makeGetValue('va_arg', 0, '*') }}}); |