From Jérôme Duval <jerome.duval@xxxxxxxxx>:
Jérôme Duval has uploaded this change for review. (
https://review.haiku-os.org/c/haiku/+/3277 ;)
Change subject: block_cache: use _sPrintf when not built in kernel mode
......................................................................
block_cache: use _sPrintf when not built in kernel mode
this is used by userlandfs
---
M src/system/kernel/cache/block_cache.cpp
1 file changed, 15 insertions(+), 9 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/77/3277/1
diff --git a/src/system/kernel/cache/block_cache.cpp
b/src/system/kernel/cache/block_cache.cpp
index ca5c112..c69d799 100644
--- a/src/system/kernel/cache/block_cache.cpp
+++ b/src/system/kernel/cache/block_cache.cpp
@@ -33,14 +33,20 @@
// TODO: the retrieval/copy of the original data could be delayed until the
// new data must be written, ie. in low memory situations.
+#ifdef _KERNEL_MODE
+# define TRACE_ALWAYS(x...) dprintf(x)
+#else
+extern "C" int _sPrintf(const char *, ...) _PRINTFLIKE(1, 2);
+# define TRACE_ALWAYS(x...) _sPrintf(x)
+#endif
+
//#define TRACE_BLOCK_CACHE
#ifdef TRACE_BLOCK_CACHE
-# define TRACE(x) dprintf x
+# define TRACE(x) TRACE_ALWAYS(x)
#else
# define TRACE(x) ;
#endif
-#define TRACE_ALWAYS(x) dprintf x
// This macro is used for fatal situations that are acceptable in a running
// system, like out of memory situations - should only panic for debugging.
@@ -1281,8 +1287,8 @@
if (written != (ssize_t)blockSize) {
TB(Error(fCache, block->block_number, "write failed", written));
- TRACE_ALWAYS(("could not write back block %" B_PRIdOFF "
(%s)\n", block->block_number,
- strerror(errno)));
+ TRACE_ALWAYS("could not write back block %" B_PRIdOFF "
(%s)\n", block->block_number,
+ strerror(errno));
if (written < 0)
return errno;
@@ -1515,7 +1521,7 @@
}
} else {
TB(Error(this, blockNumber, "allocation failed"));
- dprintf("block allocation failed, unused list is
%sempty.\n",
+ TRACE_ALWAYS("block allocation failed, unused list is
%sempty.\n",
unused_blocks.IsEmpty() ? "" : "not ");
// allocation failed, try to reuse an unused block
@@ -1831,9 +1837,9 @@
#if BLOCK_CACHE_DEBUG_CHANGED
if (!block->is_dirty && block->compare != NULL
&& memcmp(block->current_data, block->compare,
cache->block_size)) {
- dprintf("new block:\n");
+ TRACE_ALWAYS("new block:\n");
dump_block((const char*)block->current_data, 256, " ");
- dprintf("unchanged block:\n");
+ TRACE_ALWAYS("unchanged block:\n");
dump_block((const char*)block->compare, 256, " ");
BlockWriter::WriteBlock(cache, block);
panic("block_cache: supposed to be clean block was changed!\n");
@@ -1949,8 +1955,8 @@
cache->RemoveBlock(block);
TB(Error(cache, blockNumber, "read failed", bytesRead));
- TRACE_ALWAYS(("could not read block %" B_PRIdOFF ":
bytesRead: %zd, error: %s\n",
- blockNumber, bytesRead, strerror(errno)));
+ TRACE_ALWAYS("could not read block %" B_PRIdOFF ":
bytesRead: %zd, error: %s\n",
+ blockNumber, bytesRead, strerror(errno));
return errno;
}
TB(Read(cache, block));
--
To view, visit https://review.haiku-os.org/c/haiku/+/3277
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I2f7971be819c36fcab78eca2d18b45bb0b1a5fad
Gerrit-Change-Number: 3277
Gerrit-PatchSet: 1
Gerrit-Owner: Jérôme Duval <jerome.duval@xxxxxxxxx>
Gerrit-MessageType: newchange