Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / log.c
blobcc36cc74789b9e1e317b1e9eba55a1aaf8e3fa97
1 /* Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. */
5 #include "nacl_io/log.h"
7 #include "nacl_io/kernel_wrap_real.h"
9 #include <alloca.h>
10 #include <stdarg.h>
11 #include <stdio.h>
12 #include <string.h>
14 void nacl_io_log(const char* format, ...) {
15 va_list args;
16 size_t wrote;
17 char* output;
19 #ifdef _MSC_VER
20 /* TODO(sbc): vsnprintf on win32 does not return the
21 * size of the buffer needed. This can be implemented
22 * on win32 in terms of _vscprintf; */
23 #error "not implemented for win32"
24 #endif
26 va_start(args, format);
27 int len = vsnprintf(NULL, 0, format, args);
28 va_end(args);
29 output = alloca(len + 1);
31 va_start(args, format);
32 vsnprintf(output, len + 1, format, args);
33 va_end(args);
35 _real_write(2, output, strlen(output), &wrote);