summaryrefslogtreecommitdiff
path: root/src/console
diff options
context:
space:
mode:
authorVladimir Serbinenko <phcoder@gmail.com>2013-11-26 21:48:57 +0100
committerVladimir Serbinenko <phcoder@gmail.com>2013-12-07 19:27:53 +0100
commit2267658db44f7ffade5fd15cd1b8a4019a380f7e (patch)
treeb6958dd2061f42a68c16d4dfcacc91794856362b /src/console
parentf421b33edb78890f8721de49c1dd1e086f1d25fc (diff)
downloadcoreboot-2267658db44f7ffade5fd15cd1b8a4019a380f7e.tar.xz
snprintf: lockless operation
Instead of having global variables put them on the stack. Change-Id: I462e3b245612ff2dfb077da1cbcc5ac88f8b8e48 Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com> Reviewed-on: http://review.coreboot.org/4288 Reviewed-by: Ronald G. Minnich <rminnich@gmail.com> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/console')
-rw-r--r--src/console/vsprintf.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/console/vsprintf.c b/src/console/vsprintf.c
index 435401b7ef..321ce81490 100644
--- a/src/console/vsprintf.c
+++ b/src/console/vsprintf.c
@@ -20,32 +20,32 @@
*/
#include <string.h>
-#include <smp/spinlock.h>
#include <console/vtxprintf.h>
#include <trace.h>
-DECLARE_SPIN_LOCK(vsprintf_lock)
-
-static char *str_buf;
+struct vsprintf_context
+{
+ char *str_buf;
+};
-static void str_tx_byte(unsigned char byte)
+static void str_tx_byte(unsigned char byte, void *data)
{
- *str_buf = byte;
- str_buf++;
+ struct vsprintf_context *ctx = data;
+ *ctx->str_buf = byte;
+ ctx->str_buf++;
}
static int vsprintf(char *buf, const char *fmt, va_list args)
{
int i;
+ struct vsprintf_context ctx;
DISABLE_TRACE;
- spin_lock(&vsprintf_lock);
- str_buf = buf;
- i = vtxprintf(str_tx_byte, fmt, args);
- *str_buf = '\0';
+ ctx.str_buf = buf;
+ i = vtxdprintf(str_tx_byte, fmt, args, &ctx);
+ *ctx.str_buf = '\0';
- spin_unlock(&vsprintf_lock);
ENABLE_TRACE;
return i;