BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / bus_managers / ata / ATATracing.cpp
blob1f2d53f37404fdda8706d6d046004a8cc25e79ef
1 /*
2 * Copyright 2009, Michael Lotz, mmlr@mlotz.ch.
3 * Distributed under the terms of the MIT License.
4 */
6 #include "ATATracing.h"
8 #include <stdarg.h>
10 #include <algorithm>
13 static char sTraceBuffer[256];
14 static uint32 sTraceBufferOffset = 0;
17 void
18 ata_trace_printf(uint32 flags, const char *format, ...)
20 if (sTraceBufferOffset < sizeof(sTraceBuffer)) {
21 va_list arguments;
22 va_start(arguments, format);
23 size_t totalBytes = vsnprintf(sTraceBuffer + sTraceBufferOffset,
24 sizeof(sTraceBuffer) - sTraceBufferOffset, format, arguments);
25 sTraceBufferOffset += std::min(totalBytes,
26 sizeof(sTraceBuffer) - sTraceBufferOffset - 1);
27 va_end(arguments);
30 if (flags & ATA_TRACE_FLUSH) {
31 #if ATA_TRACING
32 ktrace_printf(sTraceBuffer);
33 #endif
34 if (flags & ATA_TRACE_SYSLOG)
35 dprintf(sTraceBuffer);
37 sTraceBufferOffset = 0;